problem link:- https://codeforces.me/problemset/problem/1914/E2
i am not getting the proof for the above problem please someone help me in analyzing the problem
problem link:- https://codeforces.me/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 | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 144 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | adamant | 136 |
| 8 | BledDest | 133 |
| 9 | maroonrk | 132 |
| 10 | Proof_by_QED | 131 |
| 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?