Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Python runtime error

Revision en2, by KickItLikeShika, 2020-04-02 19:57:18

I'm not good at Python but i'm trying to learn it, when i always submit a solution to Codeforces i always get run time error, but if i made the same solution in c++ it's okay and accepted, and here is an example. This is the problem set: https://codeforces.com/problemset/problem/1206/B

and here is my solution, all is well in my terminal window but i get run time error even in the first test case, i submit PyPy 3.6 or Python 3.7.2, i tried both

n = int(input())
    # ls = []
    counter = 0
    i = 0
    for i in range(n):
        k = int(input())
        # ls.append(k)
        if k > 1:
            counter += (k - 1)
        elif k < -1:
            counter += abs((k + 1))
        else:
            counter += 1
    print(counter)

and thank you.

Tags #python 3, #running time

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English KickItLikeShika 2020-04-02 19:57:18 76
en1 English KickItLikeShika 2020-04-02 19:56:09 748 Initial revision (published)