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

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

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
  • Проголосовать: не нравится

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

When Bobs win?

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    There's no 'win or loose' the optimal strategy is to maximize the difference between their points.

»
11 лет назад, # |
  Проголосовать: нравится 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..

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    well, on 3 2 board you should get both cards

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Well, the first example seems a little bit weird. Thinking about optimal strategies, as there's no restriction to the number of cards a player can pick, start picking all cards seems always better, for the first example, Alice should pick 1 + 3 + 1 to get a difference of (5 — 0) which is higher than 2, also, pick 1 + 3 and leave 1 to Bob is higher than 2. Your idea explained below gives this outcomes for the first example.

»
11 лет назад, # |
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

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Sorry but I yet can't understand your dp recurrence.

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      How many points we will win if we will get cards a[i], a[i + 1], a[i + 2], a[n] ?

      First we'll get a[i] because array is sorted, and than opponent will win dp[i - 1] (it's already calculated). We need to choose maximum.

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Do you see any segment tree in my solution, which got accepted :D?

    http://pastebin.com/TyCyK9b4

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

    Excuse me, maybe I misunderstood the problem or your solution, but in this case:

    7

    1000 500 499 100 99 10 9

    if Alice and Bob choose maximum number, then Alice get 1000 + 499 + 99 + 9 = 1607 and Bob get 500 + 100 + 10 = 610 point and the difference would be 997, but Because the both Alice and Bob play optimally, after Alice chose 1000 Bob should choose 500 and 499 then Alice should choose 100 and 99 and finally Bob choose 10 and 9 then the difference would be 591.

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Maybe I didn't write it clear enough, but I mean one should take some cards (1 or more) so that if he take cards with number x, he also take all cards with numbers greater than x