Problem:


Score : 300 points

Problem Statement

We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.

It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).

Consider the following action:

Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.

How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Constraints

1 \leq N, M \leq 200000

1 \leq K \leq 10^9

1 \leq A_i, B_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M K
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M

Output

Print an integer representing the maximum number of books that can be read.

Sample Input 1

3 4 240
60 90 120
80 150 80 150

Sample Output 1

3

In this case, it takes us 60, 90, 120 minutes to read the 1-st, 2-nd, 3-rd books from the top on Desk A, and 80, 150, 80, 150 minutes to read the 1-st, 2-nd, 3-rd, 4-th books from the top on Desk B, respectively.

We can read three books in 230 minutes, as shown below, and this is the maximum number of books we can read within 240 minutes.

Read the topmost book on Desk A in 60 minutes, and remove that book from the desk.

Read the topmost book on Desk B in 80 minutes, and remove that book from the desk.

Read the topmost book on Desk A in 90 minutes, and remove that book from the desk.

Sample Input 2

3 4 730
60 90 120
80 150 80 150

Sample Output 2

7

Sample Input 3

5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000

Sample Output 3

0

Watch out for integer overflows.



Sample input:
3 4 240
60 90 120
80 150 80 150


Sample output:
3

Submission status: Runtime Error

Solution code:
from collections import deque

N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

read_time = 0
read_num = 0

while read_time<=K:
    if len(A)==0 and len(B)==0:
        break
    elif len(A)==0:
        r = B.popleft()
        if K>=read_time+r:
            read_num += 1
            read_time += r
        continue
    elif len(B)==0:
        r = A.popleft()
        if K>=read_time+r:
            read_num += 1
            read_time += r
        continue
    if(A[0]<B[0]):
        r = A.popleft()
        if K>=read_time+r:
            read_num += 1
            read_time += r
    else:
        r = B.popleft()
        if K>=read_time+r:
            read_num += 1
            read_time += r
print(read_num

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
X = 0
Y = 0
cnt = 0
for n in range(N):
    a[n+1] = a[n] + A[n]
for n in range(M):
    b[n+1] = b[n] + B[n]
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)

Submission status: Runtime Error

Solution code:
arr1=[]
arr2=[]
satu=0
num1,num2,time=map(int,input().split())
arr1+=map(int,input().split())
arr2+=map(int,input().split())
order1=0
order2=0


while time>=0:
    if arr1[order1]<arr2[order2]:
        time-=arr1[order1]
        order1+=1
    elif arr1[order1]>arr2[order2]:
        time-=arr2[order2]
        order2+=1
    satu+=1
print(satu)

Submission status: Runtime Error

Solution code:
arr1=[]
arr2=[]
satu=0
num1,num2,time=map(int,input().split())
arr1+=map(int,input().split())
arr2+=map(int,input().split())
order1=0
order2=0


for n in range(num1+num2):
    while time>=0:
        if arr1[order1]<=arr2[order2]:
            time-=arr1[order1]
            order1+=1
        else:
            time-=arr2[order2]
            order2+=1
        satu+=1
print(satu)

Submission status: Runtime Error

Solution code:
arr1=[]
arr2=[]
satu=0
num1,num2,time=map(int,input().split())
arr1+=map(int,input().split())
arr2+=map(int,input().split())
order1=0
order2=0

while time>=0:
    for n in range(num1+num2):
        if arr1[order1]<=arr2[order2]:
            time-=arr1[order1]
            order1+=1
        else:
            time-=arr2[order2]
            order2+=1
        satu+=1

print(satu)

Submission status: Runtime Error

Solution code:
#n = a の本:m = b の本
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = 0
z = 0
i = 0
j = 0

while p < k:
    if a[i] <= b[j]:
        p += a[i]
        z += 1
        i += 1
    else:
        p += b[j]
        z += 1
        j += 1
    if p > k:
        z -= 1

print(z)

Submission status: Runtime Error

Solution code:
#n = a の本:m = b の本
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = 0
z = 0
i = 0
j = 0

while p < k:
    if a[i] < b[j]:
        p += a[i]
        z += 1
        i += 1
    elif a[i] > b[j]:
        p += b[j]
        z += 1
        j += 1
    else:
        if a[i+1] < b[j+1]:
            p += a[i]
            z += 1
            i += 1
        elif:
            p += b[j]
            z += 1
            j += 1

print(z)

Submission status: Runtime Error

Solution code:
#n = a の本:m = b の本
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = 0
i = 0
j = 0
while p < k:
    if a[i] < b[j]:
        p += 1
        i += 1
    elif a[i] > b[j]:
        p += 1
        j += 1
    else:
        if a[i+1] < b[j+1]:
            p += 1
            i += 1
        else:
            p += 1
            j += 1

print(p)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
X = 0
Y = 0
cnt = 0
for n in range(N):
    a[n+1] = a[n] + A[n]
for n in range(M):
    b[n+1] = b[n] + B[n]
for n in range(1, N+1):
    if a[n] <= K:
        X = n
for m in range(1, M+1):
    if b[m] <= K:
        Y = m 
if a[X] < b[Y]:
    K = K - a[X]
    cnt += X
    if K - b[Y] == 0:
        cnt += Y
    else:
        for y in range(1, Y+1):
            if b[y] < K:
                cnt += 1
else:
    K = K - b[Y]
    cnt += Y
    if K - a[X] == 0:
        cnt += X
    else:
        for x in range(1, X+1):
            if b[x] < K:
                cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
arr1=[]
arr2=[]
satu=0
num1,num2,time=map(int,input().split())
arr1+=map(int,input().split())
arr2+=map(int,input().split())
arr3=arr1+arr2
for n in range(num1+num2):
    time-=arr3.sort()[n]
    if time<0:
        break
    else:satu+=1
print(satu)

Submission status: Runtime Error

Solution code:
arr1=[]
arr2=[]
satu=0
num1,num2,time=map(int,input().split())
arr1+=map(int,input().split())
arr2+=map(int,input().split())
arr3=arr1+arr2
for n in range(num1+num2):
    time-=arr3.sort()[n]
    if time<=0:
        break
    else:satu+=1
print(satu)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
X = 0
Y = 0
cnt = 0
for n in range(N):
    a[n+1] = a[n] + A[n]
for n in range(M):
    b[n+1] = b[n] + B[n]
for n in range(1, N+1):
    if a[n] <= K:
        X = n
for m in range(1, M+1):
    if b[m] <= K:
        Y = m 
if a[X] < b[Y]:
    K = K - a[X]
    cnt += X
    if K - b[Y] == 0:
        cnt += Y
    else:
        for y in range(1, Y):
            if b[y] <= K:
                cnt += 1
else:
    K = K - b[Y]
    cnt += Y
    if K - a[X] == 0:
        cnt += X
    else:
        for x in range(1, X):
            if b[x] <= K:
                cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)
X = 0
Y = 0
cnt = 0
for n in range(N):
    a[n+1] = a[n] + A[n]
for n in range(M):
    b[n+1] = b[n] + B[n]
for n in range(1, N+1):
    if a[n] <= K:
        X += 1
    else:
        break
for m in range(1, M+1):
    if b[m] <= K:
        Y += 1 
    else:
        break
if a[X] < b[Y]:
    K = K - a[X]
    cnt += X
    if K - b[Y] == 0:
        cnt += Y
    else:
        for y in range(1, Y):
            if b[y] <= K:
                cnt += 1
            else:
                break
else:
    K = K - b[Y]
    cnt += Y
    if K - b[X] == 0:
        cnt += X
    else:
        for x in range(1, X):
            if b[x] <= K:
                cnt += 1
            else:
                break
print(cnt)

Submission status: Runtime Error

Solution code:
N, M, K = input().split()
Ai = input().split()[::-1]
Bi = input().split()[::-1]

As = [Ai[0]]
for i in range(1, len(Ai)):
  a = As[i-1] + Ai[i]
  if a > K:
    break
  As.append(a)
  
Bs = [Bi[0]]
for i in range(1, len(Bi)):
  b = Bs[i-1] + Bi[i]
  if b > K:
    break
  Bs.append(b)

n = 0
for i in range(0, As):
  k = K - As[i]
  for j in range(0, Bs):
    if k > Bs[j]:
      n = max(n, i+j+1)
      break

print(n)

Submission status: Runtime Error

Solution code:
from collections import deque
n,m,k = map(int,input().split())
la = list(map(int,input().split()))
lb = list(map(int,input().split()))
ls = la + lb[::-1]
ls = deque(ls)
inf = float("inf")
dp = [[-inf]*(k+1) for _ in range(n+m+1)]
for j in range(k+1):
    dp[0][j] = 0
for i in range(n+m):
    if ls == deque([]):
        break
    elif ls[0] <= ls[-1]:
        s = ls.popleft()
    elif ls[-1] < ls[0]:
        s = ls.pop()
    for l in range(k+1):
        if l-s >=0:
            dp[i+1][l] = max(dp[i][l],dp[i][l-s]+1)
        else:
            dp[i+1][l] = dp[i][l]
print(dp[-1][k])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
lis1=list(map(int,input().split()))
lis2=list(map(int,input().split()))
s=0
d=0
i=0
j=0
while(s<=c and c<=len(lis1)+len(lis2) and i<len(lis1) and j<len(lis2)):
  if(lis[i]<=lis[j]):
    s+=lis1[i]
    i+=1
    d+=1
  else:
    s+=lis2[j]
    j+=1
    d+=1
if(s>c):
  print(d-1)
elif(i==len(lis1)):
  while(s<=c and j<len(lis2)):
    s+=lis2[j]
    d+=1
    j+=1
  print(d-1)
else:
  while(s<=c and i<len(lis1)):
    s+=lisi[i]
    d+=1
    i+=1
  print(d-1)

Submission status: Runtime Error

Solution code:
N,M,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def Cum(X):
    temp = 0
    Cum = [0]*len(X)
    for i in range(len(X)):
        temp += X[i]
        Cum[i] += temp
    return Cum

a = Cum(A)
a.insert(0,0)
b = Cum(B)
b.insert(0,0)

na = 0
for i in range(N+1):
    if i == N and a[i]<=K:
        na = N
    elif a[i]<=K and a[i+1]>K:
        na = i

ans = na
temp = K-a[na]
nb = 0
for i in range(na,-1,-1):
    for j in range(nb,M+1):
        if j == M and b[i] <= temp:
            nb = M
        elif b[j]<=temp and b[j+1]>temp:
            nb = j
        ans = max(ans,i+nb)
print(ans)

Submission status: Runtime Error

Solution code:
N,M,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def Cum(X):
    temp = 0
    Cum = [0]*len(X)
    for i in range(len(X)):
        temp += X[i]
        Cum[i] += temp
    return Cum

a = Cum(A)
a = a.insert(0,0)
b = Cum(B)
b = b.insert(0,0)


def f(X,x,target):
    return X[x]-target

def nibutan(X):
    num = list(range(len(X)))
    lo = 0
    hi = len(X)
    while hi-lo>=2:
        mid = (lo+hi)//2
        if f(X,mid,Y)<=0:
            lo = mid
        else:
            hi = mid
    return lo

ans = 0
for i in range(N):
    if K-a[i]>=0:
        Y = K-a[i]
        ans = max(nibutan(b)+i,ans)
    else:
        break
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re



def main_sum():
    N,M,K=map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    A_len = len(A)
    maxB = len(B)

    Asum = [0] * (200000 + 1)

    maxA = 0

    add = 0
    for i in range(1,A_len+1):
        add += A[i-1]
        Asum[i] = add
        if add <= K:
            maxA = i + 1
        else:
            break

    ans = maxA
    prevmax = 0
    Bsum = 0
    for i in reversed(range(maxA)):
        for j in range(prevmax,maxB):
            Bsum += B[j]
            if Asum[i] + Bsum <= K:
                if ans < i + (j + 1):
                    ans = i + (j + 1)
                    prevmax = j

                if j == maxB - 1
                    print(ans)
                    exit()
            else:
                break


    print(ans)

main_sum()

Submission status: Runtime Error

Solution code:
n, m, k = map(int, input().split())
a_ = list(map(int, input().split()))
b_ = list(map(int, input().split()))

a = [0]
for i in range(n):
    a.append(a[i]+a_[i])

b = [0]
for i in range(m):
    b.append(b[i]+b_[i])

for i in range(n):
    j = m
    if a[i] > k:
        break
    while 1:
        if b[j] < k - a[i]:
            break
        j -= 1

print(i+j)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i] + A[i])
B_sum = [0]
for i in range(N):
    B_sum.append(B_sum[i] + B[i])
B_sum.append(10**10)

res = 0
for i in range(len(A_sum)):
    low = 0
    high = len(B_sum)
    while high - low > 1:
        mid = (low + high) // 2
        if A_sum[i] + B_sum[mid] <= K:
            low = mid
        else:
            high = mid
    if A_sum[i] + B_sum[low] <= K:
        res = max(res, i + low)

print(res)

Submission status: Runtime Error

Solution code:
n,m,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
for i in range(1,n):
    al[i]+=al[i-1]
for i in range(1,m):
    bl[i]+=bl[i-1]
ans=0
j=m-1
for i in range(n):
    if al[i]>k:
        break
    while bl[j]>k-al[i]:
        j-=1
    ans=max(ans,i+j+2)
print(ans)

Submission status: Runtime Error

Solution code:
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

from collections import deque
a = deque([x for x in a])
b = deque([x for x in b])
a.append(10**9+1)
b.append(10**9+1)
ans = 0
def cnt(a,b,time):
  global ans
  #print(ans, time,a,b)
  if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):
    if a[0] < b[0]:
      time += a[0]
      a.popleft()
    else:
      time += b[0]
      b.popleft()
    if time <= k:
      ans += 1
      cnt(a,b,time)

cnt(a,b,0)
print(ans)

Submission status: Runtime Error

Solution code:
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])

#print(A,B)

maxij = 0
l = m
for i in range(n+1):
	for j in range(m):
#		print(i,l,A[i],B[l],k)
		if((A[i]+B[l]) <= k):
		 	maxij=max(maxij,i+l)
#		 	print("mm",maxij)
		 	break
		else:
		 	l-=1
print(maxij)

Submission status: Runtime Error

Solution code:
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])

print(A,B)

maxij = 0
l = m
for i in range(n+1):
	for j in range(m):
#		print(i,l,A[i],B[l],k)
		if((A[i]+B[l]) <= k):
		 	maxij=max(maxij,i+l)
#		 	print("mm",maxij)
		 	break
		else:
		 	l-=1
print(maxij)

Submission status: Runtime Error

Solution code:
n,m,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
for i in range(1,n):
    al[i]+=al[i-1]
for i in range(1,m):
    bl[i]+=bl[i-1]
ans=0
j=m-1
for i in in range(n):
    if al[i]>k:
        break
    while bl[j]>al[i]-k:
        j-=1
    ans=max(ans,i+j)
print(ans)

Submission status: Runtime Error

Solution code:
n,m,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
for i in range(1,n):
    al[i]+=al[i-1]
for i in range(1,m):
    bl[i]+=bl[i-1]
ans=0
j=m
for i in in range(n):
    if al[i]>k:
        break
    while bl[j]>al[i]-k:
        j-=1
    ans=max(ans,i+j)
print(ans)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acc = sum(B)
j = M - 1
if acc + sum(A) <= K:
    print(M + N)
    exit()
ans = 0
for i in range(N):
    acc += A[i]
    if acc <= K:
        ans = max(ans, i + j + 2)
        continue
    else:
        while acc > K:
            acc -= B[j]
            j -= 1
            if (j == -1) & (acc > K):
                print(ans)
                exit()
        ans = max(ans, i + j + 2)
print(ans)

Submission status: Runtime Error

Solution code:
N, M, k = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

Submission status: Runtime Error

Solution code:
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

Submission status: Runtime Error

Solution code:
Source Code 

Copy
Copy
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)
print(ct)

Submission status: Runtime Error

Solution code:
x,y,z= map(int,input().split())
left = list(map(int,input().split()))
right = list(map(int,input().split()))
array = left+right
array.sort()
#print(array)
x=[]
for i in range(len(array)):
  x[i]=0
for i in range(len(array)):
  x[i]=array.pop(0)
  #print(sum(x))
  if (sum(x) > z):
    x.pop(-1)
    break
#print(left+right)
#print(z)
#print(sum(x))
#print(x)
print(len(x))

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if (int(A[0])>K) & (int(B[0])>K):
  pass
else: 
  while(timer <= K ):
    if (len(A) == 0) & (len(B) == 0):
      break
    elif (int(A[0]) > K - timer) & (int(B[0]) > K - timer):
      break
    elif (len(A) > 0) & (len(B) > 0):
      timer += min(int(A[0]),int(B[0]))
      if timer <= K:
        counter += 1
      elif timer > K:
        break
      if min(int(A[0]),int(B[0])) == int(A[0]):
        A.remove(A[0])
        if timer <= K:
          counter += 1
        else:
          break
        
      elif min(int(A[0]),int(B[0])) == int(B[0]):
        B.remove(B[0])
        if timer <= K:
          counter += 1
        else:
          break
    elif len(A) == 0 & len(B) != 0:
      timer += int(B[0])
      B.remove(B[0])
      if timer <= K:
        counter += 1
      else:
        break
    elif len(B) == 0 & len(A) != 0:
      timer += int(A[0])
      A.remove == 0
      if timer <= K:
        counter += 1
      else:
        break
    
print(counter)

Submission status: Runtime Error

Solution code:
import sys
from functools import reduce

def _main():
    n, m, k = map(int, sys.stdin.readline().split(" "))
    a = list(map(int, sys.stdin.readline().split(" ")))
    b = list(map(int, sys.stdin.readline().split(" ")))

    bestScore = 0
    _k = 0
    _ai = 0

    while _k < k and _ai < n:
        _k = _k + a[_ai]
        if _k > k:
            _k = _k - a[_ai]
            bestScore = _ai
            break
        _ai = _ai + 1

    _bi = 0

    while _bi < m and _ai >= 0:
        _k = _k + b[_bi]

        while _k > k and _ai >= 0:
            _k = _k - a[_ai] 
            _ai = _ai - 1

        _bi = _bi + 1

        if _k <= k and _ai + _bi > bestScore:
            bestScore = _ai + _bi

    print(bestScore)

if __name__ == "__main__":
    _main()

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if int(A[0])>K & int(B[0])>K:
  continue
else: 
  while(timer <= K ):
    if (len(A) == 0) & (len(B) == 0):
      break
    elif (len(A) > 0) & (len(B) > 0):
      timer += min(int(A[0]),int(B[0]))
      if timer <= K:
        counter += 1
      elif timer > K:
        break
      if min(int(A[0]),int(B[0])) == int(A[0]):
        A.remove(A[0])
      elif min(int(A[0]),int(B[0])) == int(B[0]):
        B.remove(B[0])
    elif len(A) == 0:
      timer += int(B[0])
      B.remove(B[0])
      if timer <= K:
        counter += 1
      else:
        break
    elif len(B) == 0:
      timer += int(A[0])
      A.remove == 0
      if timer <= K:
        counter += 1
      else:
        break
    
print(counter)

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if int(A[0])>K & int(B[0])>K:
  break
else: 
  while(timer <= K ):
    if (len(A) == 0) & (len(B) == 0):
      break
    elif (len(A) > 0) & (len(B) > 0):
      timer += min(int(A[0]),int(B[0]))
      if timer <= K:
        counter += 1
      elif timer > K:
        break
      if min(int(A[0]),int(B[0])) == int(A[0]):
        A.remove(A[0])
      elif min(int(A[0]),int(B[0])) == int(B[0]):
        B.remove(B[0])
    elif len(A) == 0:
      timer += int(B[0])
      B.remove(B[0])
      if timer <= K:
        counter += 1
      else:
        break
    elif len(B) == 0:
      timer += int(A[0])
      A.remove == 0
      if timer <= K:
        counter += 1
      else:
        break
    
print(counter)

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if int(A[0])>K & int(B[0])>K:
  pass
else: 
  while(timer <= K ):
    if (len(A) == 0) & (len(B) == 0):
      break
    elif ((int(A[0]) + timer) > K ) & ((int(B[0]) + timer) > K):
      break
    elif (len(A) > 0) & (len(B) > 0):
      timer += min(int(A[0]),int(B[0]))
      if timer <= K:
        counter += 1
      elif timer > K:
        break
      if min(int(A[0]),int(B[0])) == int(A[0]):
        A.remove(A[0])
      elif min(int(A[0]),int(B[0])) == int(B[0]):
        B.remove(B[0])
    elif len(A) == 0:
      timer += int(B[0])
      B.remove(B[0])
      if timer <= K:
        counter += 1
      else:
        break
    elif len(B) == 0:
      timer += int(A[0])
      A.remove == 0
      if timer <= K:
        counter += 1
      else:
        break
    
print(counter)

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if int(A[0])>K & int(B[0])>K:
  pass
else: 
  while(timer <= K ):
    if ((int(A[0]) + timer)> K ) & ((int(B[0]) + timer ) > K):
      break
    else:
      if (len(A) == 0) & (len(B) == 0):
      	break
      elif (len(A) > 0) & (len(B) > 0):
        timer += min(int(A[0]),int(B[0]))
        if timer <= K:
          counter += 1
        elif timer > K:
          break
        if min(int(A[0]),int(B[0])) == int(A[0]):
          A.remove(A[0])
        elif min(int(A[0]),int(B[0])) == int(B[0]):
          B.remove(B[0])
      elif len(A) == 0:
        timer += int(B[0])
        B.remove(B[0])
        if timer <= K:
          counter += 1
        else:
          break
      elif len(B) == 0:
        timer += int(A[0])
        A.remove == 0
        if timer <= K:
          counter += 1
        else:
          break
    
print(counter)

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if int(A[0])>K & int(B[0])>K:
  pass
else: 
  while(timer <= K ):
    if (len(A) == 0) & (len(B) == 0):
      break
    elif ((int(A[0]) + timer )> K ) & ((int(B[0] + timer )) > K):
      break
    elif (len(A) > 0) & (len(B) > 0):
      timer += min(int(A[0]),int(B[0]))
      if timer <= K:
        counter += 1
      elif timer > K:
        break
      if min(int(A[0]),int(B[0])) == int(A[0]):
        A.remove(A[0])
      elif min(int(A[0]),int(B[0])) == int(B[0]):
        B.remove(B[0])
    elif len(A) == 0:
      timer += int(B[0])
      B.remove(B[0])
      if timer <= K:
        counter += 1
      else:
        break
    elif len(B) == 0:
      timer += int(A[0])
      A.remove == 0
      if timer <= K:
        counter += 1
      else:
        break
    
print(counter)

Submission status: Runtime Error

Solution code:
x,y ,z= map(int,input().split())
left = list(map(int,input().split()))
right = list(map(int,input().split()))
array = left+right
array.sort()
x=[]
for i in array:
  x[i]=array.pop(0)
  if (sum(x)>z):
    x.pop(-1)
print(len(x))

Submission status: Runtime Error

Solution code:
N, M, K= map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

count=0
time=0

while time <= K:
    if A == [] and B==[]:
        break
    if K < A[0] or K < B[0]:
        break       
    else:
        if A == [] and B != []:
            count+=1
            if K >= time + B[0]:
                time += B[0]
                del B[0]
        elif A != [] and B ==[]:
            count += 1
            if K>= time + A[0]:
                time += A[0]
                del A[0]
        else:
            if A[0] > B[0]:
                count += 1
                time += A[0]
                del A[0]
            else:
                count += 1
                time += B[0]
                del B[0]


print(count)

Submission status: Runtime Error

Solution code:
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
M = int(input())
dq = [list(map(int, input().split())) for _ in range(M)]

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

for i in range(M):
  t[dq[i][0]-1] = dq[i][1]
  print(calc(t, D, s))

Submission status: Runtime Error

Solution code:
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k> 0: 
  if A[i] < B[j] and k-A[i] > 0: 
    k -= A[i]
    i +=1
    ct +=1
  elif k-B[j] > 0: 
    k -= B[j]
    j +=1
  	ct += 1
print(ct)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[n+1];
	ll b[m+1];
	a[0]=0;
	b[0]=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(ll i=1;i<=m;i++)
	{
		cin>>b[i];
		b[i]+=b[i-1];
	}
	ll j=m;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if(a[i]>k)break;
		while(j>=0 && a[i]+b[j]>k)
		{
			j--;
		}
		if(j>=0)
		ans=max(ans,i+j);
	}
	cout<<ans;
	return 0;
}

Submission status: Runtime Error

Solution code:
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if A[i] < B[j] and k - A[i] > 0: 
    k -= A[i]
    i +=1
  elif k - B[j] > 0: 
    k -= B[j]
    j +=1
  ct += 1
print(ct)

Submission status: Runtime Error

Solution code:
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

timer = 0
counter = 0

if int(A[0])>K & int(B[0])>K:
	pass
else: 
    while(timer <= K ):
    	if (len(A) == 0) & (len(B) == 0):
        	break
        elif (len(A) > 0) & (len(B) > 0):
            timer += min(int(A[0]),int(B[0]))
            if timer <= K:
            	counter += 1
            elif timer > K:
                break
            if min(int(A[0]),int(B[0])) == int(A[0]):
                A.remove(A[0])
            elif min(int(A[0]),int(B[0])) == int(B[0]):
                B.remove(B[0])
        elif len(A) == 0:
            timer += int(B[0])
            B.remove(B[0])
            if timer <= K:
                counter += 1
            else:
                break
        elif len(B) == 0:
            timer += int(A[0])
            A.remove == 0
            if timer <= K:
                counter += 1
            else:
                break
    

print(counter)

Submission status: Runtime Error

Solution code:
N, M, K= map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

count=0
time=0

while time <= K:
    if K < A[0] or K<B[0]:
        break
    elif A == [] and B==[]:
        break
    else:
        if A == [] and B != []:
            count+=1
            if K >= time + B[0]:
                time += B[0]
                del B[0]
        elif A != [] and B ==[]:
            count += 1
            if K>= time + A[0]:
                time += A[0]
                del A[0]
        else:
            if A[0] > B[0]:
                count += 1
                time += A[0]
                del A[0]
            else:
                count += 1
                time += B[0]
                del B[0]


print(count)

Submission status: Runtime Error

Solution code:
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if A[i] < B[j]: 
    k -= A[i]
    i +=1
  else: 
    k -= B[j]
    j +=1
  ct += 1
print(ct)

Submission status: Runtime Error

Solution code:
n, m, k = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

a_idx = b_idx = 0
count = 0
time = 0

while time < k:
    if a_idx == n or A[a_idx] >= B[b_idx]:
        time += B[b_idx]
        b_idx += 1
    elif b_idx == m or A[a_idx] < B[b_idx]:
        time += A[a_idx]
        a_idx += 1
        
    if time > k:
        break
    count += 1
    
    if a_idx+b_idx == n+m or time==k:
        break
    
print(count)

Submission status: Runtime Error

Solution code:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
time = 0
count = 0
while True:
    aa = a[0]
    bb = b[0]
    if(aa < bb):
        time+=aa
        a.pop(0)
    else:
        time+=bb
        b.pop(0)
    if(time > k):
        break
    count += 1
    
print(count)