Hummus_'s blog

By Hummus_, history, 4 months ago, In English

In this problem: https://codeforces.com/contest/1608/problem/C I keep getting WA and I don't know exactly what is wrong with my code

Approach: I make 2 arrays that represent the value of A and the value of B and then sort them according to the value in ascending order. After that, I go through the array A from the end till the beginning and for each i I see if it can beat the biggest A in the second map which is B, and if this is true then this i can win the game. after I finish with array A I do the same thing with array B.

Code: https://ideone.com/txcuRy

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

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

It's because your condition is correct but not enough. For ex A — > 6 5 7 4 8 B — > 5 11 13 8 9 Consider the 1st person, your code will flag it as 0 which is incorrect as there's a way through which 1 can win. (1 can beat 2 in A) (2 can beat 5 in B) (5 can beat everyone else in A) The point is a person need not directly defeat the strongest in other map but it can defeat someone who is capable of doing that.

  • »
    »
    4 months ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    It actually works as u say the first person can win in my code !

    I think i am applying what you are saying so in the A array for example if an element at ith position can kill the biggest A in the B map all the elements that are at positions greater then or equal to this position at array A can win