Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
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
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):
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

time = 0
count = 0
i = 0
j = 0
for _ in range(n + m):
    if i > len(a) - 1:
        time += b[j]
        j += 1
    elif j > len(b) -1 :
        time += a[i]
        i += 1
    elif i > len(a)-1 and j > len(b)-1:
        break
    else:
        if a[i] < b[j]:
            time += a[i]
            i +=1
        elif a[i] > b[j]:
            time += b[j]
            j +=1
        else:
            time += a[i]
            if a[i + 1] < b[j+1]:
                i += 1
            else:
                j += 1
    if time > k:
        break
    else:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

time = 0
count = 0
i = 0
j = 0
for _ in range(n + m):
    if a[i] < b[j]:
        time += a[i]
        i +=1
    elif a[i] > b[j]:
        time += b[j]
        j +=1
    else:
        time += a[i]
        if a[i + 1] < b[j+1]:
            i += 1
        else:
            j += 1
    if time > k:
        break
    else:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

time = 0
count = 0
for _ in range(n + m):
    if len(a) > 0 and len(b)>0:
        if a[0] < b[0]:
            time += a[0]
            a = a[1:]
        else:
            time += b[0]
            b = b[1:]
    elif len(a) == 0 and len(b) > 0:
        time += b[0]
        b = b[]
    elif len(b) == 0 and len(a) > 0:
        time += a[0]
        a = a[:-1]
    if time > k:
        break
    else:
        count += 1
        
        
print(count)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

time = 0
count = 0
for _ in range(n + m):
    if len(a) > 0and len(b)>0:
        if a[-1] < b[-1]:
            time += a[-1]
            a = a[:-1]
        else:
            time += b[-i-1]
            b = b[:-1]
    elif len(a) == 0 and len(b) > 0:
        time += b[-1]
        b = b[:-1]
    elif len(b) == 0 and len(a) > 0:
        time += a[-1]
        a = a[:-1]
    if time > k:
        break
    else:
        count += 1
        
        
print(count)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

time = 0
count = 0
for _ in range(n * m):
    if len(a) > 0and len(b)>0:
        if a[-1] < b[-1]:
            time += a[-1]
            a = a[:-1]
        else:
            time += b[-i-1]
            b = b[:-1]
    elif len(a) == 0:
        time += b[-1]
        b = b[:-1]
    elif len(b) == 0:
        time += a[-1]
        a = a[:-1]
    if time > k:
        print(count)
        break
    else:
        count += 1

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

time = 0
count = 0
for _ in range(N * M):
    if a[-1] < b[-1]:
        time += a[-1]
        a = a[:-1]
    else:
        time += b[-i-1]
        b = b[:-1]
    if time > k:
        print(count)
        break
    else:
        count += 1