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

Автор catalystgma, история, 5 лет назад, По-английски

Hi,

I am trying to solve problem https://codeforces.me/contest/372/problem/A .

This is my sourcecode: http://cpp.sh/3rqwk. My codeforces submission is here: https://codeforces.me/contest/372/submission/55705312.

My code runs on my computer and cpp.sh on the two examples successfully but gets "Runtime Error" with a huge descrpition on the site. I know how volatile the are multiset erase operations, but I can't figure out why it won't run specifically on codeforces.

Thank you!

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

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

    Thanks, it helped. It seems that you have to copy the incremented iterator before attempting to erase. Weird how it works on some compilers without copying.

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

      Not really, you should do it = ss.erase(it) for since C++11 erase(it) always returns iterator next to it. And no copy is really need.
      P.S. In your case it would be even better if you use multiset sorted by descending.