Python runtime error
Difference between en1 and en2, changed 76 character(s)
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.

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)