Pretest's blog

By Pretest, history, 8 years ago, In English

I have got time limit exceeded in many code. But i do not know how judges calculate the execution time of a code. Can anyone tell me how codeforce calculate the execution time of a code!!!

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Hi,

I don't actually know how Codeforces calculate the execution time of code, but here is a simple example (In linux environment), you can use the timeout command and specify the time limit.

timeout 1 "your_command_here_to_execute_the_program"

If the execution is completed within the time limit (1 second in this case), the programm will exit with the status of COMMAND, otherwise it will exit with status 124.

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

    i am not familiar with Linux environment ...but thanks for your suggestion is there anything for windows programs

    • »
      »
      »
      8 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I don't think you need to know exactly how Codeforces calculates the execution time of your program to understand the reason why you get the Time Limit Exceeded verdict. Usually, if your program exceeds the TL, that means you are doing something much costlier than necessary and it would not be some extra fractions of seconds that would change the result.