G_Hani's blog

By G_Hani, history, 9 years ago, In English

hi everyone :)

i'm trying to solve 629D - Babaei and Birthday Cake in the last contest Codeforces Round 343 (Div. 2) ...

my idea got WA6 .. but i can't find why !! i followed the editorial can anyone help me :( here is my code 16335124

i already solved this problem 340D - Bubble Sort Graph

  • Vote: I like it
  • -6
  • Vote: I do not like it

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

not sure of what you are doing here ... why sort the values by r*r*h ?

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    from problem statement

    "in order to impress friends Babaei will put the cake i on top of the cake j only if the volume of the cake i is strictly greater than the volume of the cake j."

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      what you missed was that index of cake i is strictly greater than cake j

      in other words i>j and V[i] > v[j]

»
9 years ago, # |
  Vote: I like it +10 Vote: I do not like it

I think it's because there's something wrong! Did you understand anything from that? I bet you didn't, you understood as much as anyone who wants to help you will understand from your blog. If you need your code to be debugged, you can't just post a piece of code (those macros make it too ugly) and say "Here's the code, here's the problem, where's the bug?" :) You must explain your solution in detail and then wish someone to help you :)

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

Auto comment: topic has been updated by G_Hani (previous revision, new revision, compare).

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

I've read the code quickly, I'm not sure if this is the bug but in the line
ans[a[i].first] = query(1, 0, n - 1, 0, a[i].first) + a[i].second;
I doubt it should be ans[a[i].first] = query(1, 0, n - 1, 0, a[i].first-1) + a[i].second; because the sequence should be strictly increasing .
Just a guess