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):
import sys
import random
import bisect
from collections import deque

def cumsum(a):
    tmp = 0
    ret = []
    for i in range(len(a)):
        tmp += a[i]
        ret.append(tmp)
    return ret

x = input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n, m, k = int(x[0]), int(x[1]), int(x[2])

#n, m = 100000, 100000
#time = 100000000
#a = list(random.choices(range(10000), k=n))
#b = list(random.choices(range(10000), k=m))

a_sum, b_sum = cumsum(a), cumsum(b)

ans, j = 0, m-1
for i in range(n):
    if a_sum[i] > k:
        break
    while b_sum[j] > k-a_sum[i]:
        print(j)
        j -= 1
    ans = max(ans, i + j + 2)

print (ans)

Buggy submission (verdict: Runtime Error):
import sys
import random
import bisect
from collections import deque

def cumsum(a):
    tmp = 0
    ret = []
    for i in range(len(a)):
        tmp += a[i]
        ret.append(tmp)
    return ret

x = input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n, m, k = int(x[0]), int(x[1]), int(x[2])

#n, m = 100000, 100000
#time = 100000000
#a = list(random.choices(range(10000), k=n))
#b = list(random.choices(range(10000), k=m))

a_sum, b_sum = cumsum(a), cumsum(b)

ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
        ans = max(ans, i + j)

print (ans)

Buggy submission (verdict: Runtime Error):
import sys
import random
import bisect
from collections import deque

def cumsum(a):
    tmp = 0
    ret = []
    for i in range(len(a)):
        tmp += a[i]
        ret.append(tmp)
    return ret

x = input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n, m, time = int(x[0]), int(x[1]), int(x[2])

#n, m = 100000, 100000
#time = 100000000
#a = list(random.choices(range(10000), k=n))
#b = list(random.choices(range(10000), k=m))

a_sum, b_sum = cumsum(a), cumsum(b)

ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
        ans = max(ans, i + j)

print (ans)

Buggy submission (verdict: Runtime Error):
import sys
import random
import bisect
from collections import deque

def cumsum(a):
    tmp = 0
    ret = []
    for i in range(len(a)):
        tmp += a[i]
        ret.append(tmp)
    return ret

#x = input().split()
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
#n, m, time = int(x[0]), int(x[1]), int(x[2])

#n, m = 100000, 100000
#time = 100000000
#a = list(random.choices(range(10000), k=n))
#b = list(random.choices(range(10000), k=m))

a_sum, b_sum = cumsum(a), cumsum(b)

ans, j = 0, M
for i in range(N + 1):
    if a_sum[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
        ans = max(ans, i + j)

print (ans)

Buggy submission (verdict: Runtime Error):
import sys
import random
import bisect
from collections import deque

x = input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n, m, time = int(x[0]), int(x[1]), int(x[2])

#n, m = 100000, 100000
#time = 100000000
#a = list(random.choices(range(10000), k=n))
#b = list(random.choices(range(10000), k=m))

a_sum, b_sum = cumsum(a), cumsum(b)

a_pos = bisect.bisect_left(a_sum, time)
b_pos = bisect.bisect_left(b_sum, time)
read = 0
for i in range(a_pos):
    bpos = bisect.bisect_left(b_sum, time-a_sum[i]+.1)
    read = max(read, i+bpos+1)

print (read)

def cumsum(a):
    tmp = 0
    ret = []
    for i in range(len(a)):
        tmp += a[i]
        ret.append(tmp)
    return ret