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

Автор sasamba_bitches, история, 13 месяцев назад, По-английски

I have already seen editorial, but getting WA. Here is the problem and this is my code. Can you please help me?

Thanks!

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

»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In the function "thir" you can't write

auto it = s.lower_bound(x);
it--;

because maybe it == s.begin(). Instead of "it--" you can do "k--".

Also you should check that it != s.end(), before you do "it++" in the for loop.

And since the for loop might not be entered, you should also check that it != s.end() before you return *it in the end.

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

    It did not help.

    code

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

      Check if "it == s.end()" before you increase it.

      Spoiler