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

Автор aajjbb, 12 лет назад, По-английски

Hello, I'm trying to solve this problem from Polish Olympiad of Informatics Link. The problem seems to be straight forward, but I'm not able to figure out the optimal strategy. Currently, I think the optimal strategy is to always let Alice to take only the biggest card, an then, Bob take all the other cards, this, due to the first example which seems that points are not cumulative. Do you have any other clue to the 'optimal' strategy ?

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

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

When Bobs win?

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

I think we need to first sort the array and then Alice takes the biggest number and all numbers equal to it. Then Bob takes second biggest number and all numbers equal to it and so on until last number..

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

It seems to be true that it's always better to take number out max cards. Ok let's sort in asc order, we always need to take suffix. let dp[n] id answer on prefix. Then dp[n] = max_{i<=n}{a[i]-dp [i-1]}. Let's calculate it for every i from 1 to n. It could be done using segment tree