#这题太离谱了,不能提前终止进程,否则会判错 n,x = map(int ,input().split()) cnt = 0 move = list(map(int,input().split())) for i in range(n): if x == 0: continue elif x > 0: x -= move[i] cnt += move[i] elif x < 0: x += move[i] cnt += move[i] print(cnt)报错代码如下
n,x = map(int ,input().split()) cnt = 0 move = list(map(int,input().split())) for i in range(n): if x == 0: continue elif x > 0: x -= move[i] cnt += move[i] if x==0: print(cnt) exit() elif x < 0: x += move[i] if x==0: print(cnt) exit()