Problem p02623 (python)

Fixed submission:
#import sys
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break
    while b[l] > K - a[k]:
        l -= 1
    ans = max(ans,k+l)
print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break:
    while b[l] > K - a[k]:
        l -= 1
    ans = max(ans,k+l)
print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break:
    while b[l] + a[k] > K:
        l -= 1
    ans = max(ans,k+l)
print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[i]+B[i])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break:
    while b[l] + a[k] > K:
        l -= 1
    ans = max(ans,k+l)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[i]+B[i])
ans = 0
l = M
for k in range(N+1):
    if a[k] > K:
        break:
    while b[l] + a[k] > K:
        j -= 1
    ans = max(ans,k+j)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
time = 0
while time < K:
    if not A:
        ans += 1
        if time + B[0] > K:
            break
        time += B[0]
        B.pop(0)
    elif not B:
        ans += 1
        if time + A[0]> K:
            break
        time += A[0]
        A.pop(0)
    elif A[0] > K or B[0] > K:
        break
    elif A[0] == B[0]:
        if A[1] > B[1]:
            if time + B[0] > K:
                break
            time += B[0]
            ans += 1
            B.pop(0)
        elif A[1] < B[1]:
            if time + A[0] > K:
                break
            time += B[0]
            ans += 1
            A.pop(0)
    elif A[0] > B[0] :
        if time + B[0] > K:
            break
        time += B[0]
        ans += 1
        B.pop(0)
    elif A[0] < B[0]:
        if time + A[0] > K:
            break
        time += B[0]
        ans += 1
        A.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
time = 0
while time < K:
    if not A:
        ans += 1
        if time + B[0]:
            break
        time += B[0]
        B.pop(0)
    elif not B:
        ans += 1
        if time + A[0]:
            break
        time += A[0]
        A.pop(0)
    elif A[0] > K or B[0] > K:
        break
    elif A[0] == B[0]:
        if A[1] > B[1]:
            if time + B[0]:
                break
            time += B[0]
            ans += 1
            B.pop(0)
        elif A[1] < B[1]:
            if time + A[0]:
                break
            time += B[0]
            ans += 1
            A.pop(0)
    elif A[0] > B[0] :
        if time + B[0]:
            break
        time += B[0]
        ans += 1
        B.pop(0)
    elif A[0] < B[0]:
        if time + A[0]:
            break
        time += B[0]
        ans += 1
        A.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
time = 0
while time < K:
    if not A:
        ans += 1
        time += B[0]
        B.pop(0)
    elif not B:
        ans += 1
        time += A[0]
        A.pop(0)
    elif A[0] > K or B[0]> K:
        break
    elif A[0] == B[0]:
        if A[1] > B[1]:
            time += B[0]
            ans += 1
            B.pop(0)
        elif A[1] < B[1]:
            time += B[0]
            ans += 1
            A.pop(0)
    elif A[0] > B[0] :
        time += B[0]
        ans += 1
        B.pop(0)
    elif A[0] < B[0]:
        time += B[0]
        ans += 1
        A.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
time = 0
while time < K:
    if not A:
        ans += 1
        time += B[0]
        B.pop(0)
    elif not B:
        ans += 1
        time += A[0]
        A.pop(0)
    elif A[0] == B[0]:
        if A[1] > B[1]:
            time += B[0]
            ans += 1
            B.pop(0)
        elif A[1] < B[1]:
            time += B[0]
            ans += 1
            A.pop(0)
    elif A[0] > B[0] :
        time += B[0]
        ans += 1
        B.pop(0)
    elif A[0] < B[0]:
        time += B[0]
        ans += 1
        A.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
time = 0
while time < K:
    if not A:
        ans += 1
        time += B[0]
        B.pop(0)
    elif not B:
        ans += 1
        time += A[0]
        A.pop(0)
    elif A[0] == B[0]:
        if A[1] > B[1]:
            time += B[0]
            ans += 1
            B.pop(0)
        else A[1] < B[1]:
            time += B[0]
            ans += 1
            A.pop(0)
    elif A[0] > B[0] :
        time += B[0]
        ans += 1
        B.pop(0)
    elif A[0] < B[0]:
        time += B[0]
        ans += 1
        A.pop(0)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
time = 0
while time < K:
    if not A:
        ans += 1
        time += B[0]
        B.pop(0)
    elif not B:
        ans += 1
        time += A[0]
        A.pop(0)
    elif A[0] = B[0]:
        if A[1] > B[1]:
            time += B[0]
            ans += 1
            B.pop(0)
        else A[1] < B[1]:
            time += B[0]
            ans += 1
            A.pop(0)
    elif A[0] > B[0] :
        time += B[0]
        ans += 1
        B.pop(0)
    elif A[0] < B[0]:
        time += B[0]
        ans += 1
        A.pop(0)
print(ans)