problem link:- https://mirror.codeforces.com/problemset/problem/1914/E2
i am not getting the proof for the above problem please someone help me in analyzing the problem
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | jiangly | 3631 |
| 4 | Kevin114514 | 3574 |
| 5 | maroonrk | 3521 |
| 6 | strapple | 3515 |
| 7 | Radewoosh | 3461 |
| 8 | tourist | 3428 |
| 9 | turmax | 3378 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 162 |
| 2 | adamant | 148 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 140 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 133 |
problem link:- https://mirror.codeforces.com/problemset/problem/1914/E2
i am not getting the proof for the above problem please someone help me in analyzing the problem
| Name |
|---|



It's basically a game theory-ish problem where two players take successive turns and try to optimize their own results. Now here, the main issue is: "Which color should a player choose on the kth turn for optimal result?"
Ok so, boils down to — "The player on the kth turn pick a color i such that the benefit for him is maximum". Now let us define the term "benefit" based on the problem scenario.
Benefit by player 1 = points scored by him + points blocked for player 2 which boils down to, for a color i, benefit = a[i] + b[i] — 2; So, a player on the kth turn will greedily choose the color such that a[i] + b[i] is maximum and that will give him a score of A += a[i] — 1 if she's Alice or a score of B += b[i] — 1 if he's Bob.
So, just make a vector of pairs storing the {a[i] + b[i], i} for every index i and sort it in non increasing order and make a player choose the best possible option and add the earned score to his / her scorecard.
Finally, ans = A — B
341869939
you got it or you need more help?