#P16700. [MCO 2026] 队伍选择
[MCO 2026] 队伍选择
Problem Description
The dragon Evirir is a competitive flying coach. It trains dragon athletes, numbered . For each , athlete has speed .
Evirir needs to form a team for an upcoming group flying competition. Due to some strange rules, this team must be a contiguous segment of length at least . That is, Evirir must choose and () such that , and form a team consisting of athletes .
The strength of a team is defined as the sum of the minimum speed and the maximum speed among the athletes on the team. Please help Evirir find a team with the maximum possible strength. If multiple teams achieve the maximum strength, Evirir prefers the one with the most athletes (because a big team looks more impressive).
Input Format
The first line contains two integers and separated by spaces.
The second line contains integers separated by spaces.
Output Format
Let be the maximum strength that a team can achieve, and suppose there is a team with strength consisting of athletes . Output three integers separated by spaces: , , and (, ).
If there are multiple teams with maximum strength, output any one of them that has the largest possible number of athletes.
If you output the correct maximum strength and any valid team, you can still get partial credit. That is, output the correct , and output any integers and such that and . In particular, you can always output , , . For details about scoring, see the Scoring section.
9 3
1 2 3 3 4 3 1 5 2
7 2 5
5 2
2 2 1 2 2
4 0 1
2 1
6 7
14 1 1
Hint
Hint
This sample applies to subtasks 2, 4, 5, and 6.
Here there are athletes, and Evirir must choose a team with at least athletes. One optimal choice is and , where the athletes' speeds are , , , and . The minimum speed is and the maximum speed is , so the team strength is . Therefore the output is .
Below are some other outputs and their results.
| Output | Score | Explanation |
|---|---|---|
7 7 8 |
0% | This team contains fewer than 3 athletes. |
4 0 2 |
This team strength is not the maximum possible. | |
7 0 2 |
50% | The team strength is correct, even though the printed team is not correct. |
7 2 4 |
To get full score, the team size must be as large as possible. |
This sample applies to subtasks 2, 3, 4, 5, and 6.
Note that outputting would also get full score, because this team also achieves the maximum possible strength , and the maximum possible number of athletes is also .
This sample applies to subtasks 1, 2, 4, 5, and 6.
If the team contains only one athlete, then the team strength is twice that athlete's speed, because both the minimum speed and the maximum speed come from that athlete.
Scoring
For all test cases, the input satisfies the following Constraints:
- For all ,
For all subtasks, if you output the maximum strength and any valid team, you can get 50% of the score for that subtask.
| Subtask | Points | Additional Constraints |
|---|---|---|
| For all , | ||
| For all , | ||
| For all , | ||
| -- |
Translated by ChatGPT 5