Блог пользователя saptarshikuar2003

Автор saptarshikuar2003, история, 11 месяцев назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

you got it or you need more help?