saptarshikuar2003's blog

By saptarshikuar2003, history, 8 months ago, In English

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

»
8 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

you got it or you need more help?