Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

Автор divrthor345, история, 3 года назад, По-английски

i submited my code in python and got tle
and got ac when submiiting same code written in c
problem B
submission in python
submission in c
i think time limit for the questions should be checked for every language first
the main thing is to think of an approach in o(n)
if we use o(n^2) it will definitely gonna take more than 10 seconds
so the time limit should be set that accepts all the solutions with o(n) approach

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

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

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

»
3 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

I think you could have optimised your python code in order to avoid TLE. You can have a look at my O(n) solution in pypy3 which passed the time limit.

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

    Python and PyPy are totally different when it comes to CP. I have seen many cases where Python fails and PyPy got AC and vice versa also. This is because PyPy is not good dealing with strings and in the other cases Python is not faster than PyPy.

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

      Yes, what you said is totally true. Even I have seen codes which gave TLE in Python while AC in PyPy. I just mentioned it there because the author of this blog has also submitted his solution in PyPy.