[Solution] Swap and Take Codeforces Solution
You're given an array consisting of integers. You have to perform turns.
Initially your score is .
On the -th turn, you are allowed to leave the array as it is or swap any one pair of adjacent elements in the array and change exactly one of them to (and leave the value of other element unchanged) after swapping. In either case(whether you swap or not), after this you add to your score.
What's the maximum possible score you can get?
The first line contains a single integer ().
The second line contains integers ().
Print a single integer — the maximum possible score.
In the first example, to get the maximum score we do as follows. Do nothing on the first turn, add to the score. Swap the first and the second elements and turn to on the second turn, and add to the score. The final score is
No comments:
Post a Comment