1 / 4
Apr 2021

I have coded a solution for the TRT (Treats for the Cows) problem, which perfectly works on my local machine. However, when uploading it to SPOJ, it fails. After many tries, I have looked through the comment section where someone claims that the problem can’t be solved in Python as the time limit is too strict. I am wondering if this is really the case, as the problem description states that most languages including Python can be used. Did anyone manage to submit a Python solution?

  • created

    Apr '21
  • last reply

    Apr '21
  • 3

    replies

  • 621

    views

  • 3

    users

  • 1

    link

There are no AC Python solutions, but there are a few PyPy ones - see here7.

I’ve just resubmitted my old code and got AC with Py2 in 1.50s. It seems the problem is one of a larger group where admins have corrected an unreasonable fraction-of-a-second TL to something that can be worked with in slower languages. That said, DP problems are particularly difficult to AC with raw Python here, so submit in PyPy or make sure your code is free of unnecessary overhead (use fast IO, avoid recursion, employ efficient Py idioms etc).