__Joker's blog

By __Joker, history, 5 years ago, In English

Please find my solution at : http://codeforces.com/contest/1054/submission/44512450

The algorithm I am following is this,

for each student, find out how many student have more chocolates than him, by adding l[i] and r[i].

This basically gives the standard competition ranking. see[1].

Next step is I am simply verifying if the ranking I am getting is a standard competition ranking.

And chocolate distribution is (n-rank[i])

My solution is failing on test case 6. And I am not able to download the whole test case( it is big).

Any body will be kind enough to point out what I am doing wrong ?

[1]. https://en.wikipedia.org/wiki/Ranking#Standard_competition_ranking_(%221224%22_ranking)

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Firstly think about it — then why are they giving you the number to the left and to the right ? So it is obviously that the positioning matters. I can't find a counter example, but i think that this solution won't work. (it's not about a bug in the code)

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

try this

4
0 1 0 1
1 0 0 0
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I got an AC using this logic. You might be missing the case where you check for duplicates. Check out my code here