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
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | maspy | 150 |
| 3 | Um_nik | 146 |
| 4 | Errichto | 139 |
| 5 | adamant | 136 |
| 6 | maroonrk | 134 |
| 7 | DNR | 133 |
| 8 | nik_exists | 131 |
| 8 | Dominater069 | 131 |
| 10 | Proof_by_QED | 130 |
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
| Название |
|---|



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?