Problem p02623 (python)

Fixed submission:
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if A[i] > k:
        break
    #K<=A[i]+B[j]となるまでjを引く>>k-A<=B
    while A[i] + B[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans, j = 0, m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
i = 0
j = 0
for _ in range(n+m):
    # print(i,j,k)
    if n <= i:#
        k -= b[j]
        j += 1
        if k < 0:
            break
        ans += 1
        if k == 0:
            break
        continue
    elif n <= j:
        k -= a[i]
        i += 1
        if k < 0:
            break
        ans += 1
        if k == 0:
            break
        continue
    if a[i] < b[j]:
        k -= a[i]
        i += 1
    else:
        k -= b[j]
        j += 1
    if k < 0:
        break
    ans += 1
    if k == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
i = 0
j = 0
for _ in range(n+m)
    # print(i,j,k)
    if n <= i:#
        k -= b[j]
        j += 1
        if k < 0:
            break
        ans += 1
        if k == 0:
            break
        continue
    elif n <= j:
        k -= a[i]
        i += 1
        if k < 0:
            break
        ans += 1
        if k == 0:
            break
        continue
    if a[i] < b[j]:
        k -= a[i]
        i += 1
    else:
        k -= b[j]
        j += 1
    if k < 0:
        break
    ans += 1
    if k == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
i = 0
j = 0
for _ in range(n+m):
    # print(i,j,k)
    if n <= i:#
        k -= b[j]
        j += 1
        ans += 1
        continue
    elif n <= j:
        k -= a[i]
        i += 1
        ans += 1
        continue
    if a[i] < b[j]:
        k -= a[i]
        i += 1
    else:
        k -= b[j]
        j += 1
    if k < 0:
        break
    ans += 1
    if k == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
i = 0
j = 0
while n > i or m > j:
    # print(i,j,k)
    if n <= i:
        k -= b[j]
        j += 1
        ans+=1
        continue
    elif n <= j:
        k -= a[i]
        i += 1
        ans+=1
        continue
    if a[i] < b[j]:
        k -= a[i]
        i += 1
    else:
        k -= b[j]
        j += 1
    if k < 0:
        break
    ans += 1
    if k == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
i = 0
j = 0
while n > i or m > j:
    # print(i,j,k)
    if n <= i:
        k -= b[j]
        j += 1
        ans+=1
        continue
    elif n <= j:
        k -= a[i]
        i += 1
        ans+=1
        continue
    if a[i] < b[j]:
        k -= a[i]
        i += 1
    else:
        k -= b[j]
        j += 1
    if k < 0:
        break
    ans += 1
    if k == 0:
        break
print(ans)