Problem: 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.

Submission attempts (in order):
import numpy as np
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_np = np.array(A)
B_np = np.array(B)

C_np = np.append(A_np,B_np)
C_np = np.sort(C_np)

x = 0
for i in range(len(C_np)):
    if K > x + C_np[i]:
        x += 1
    else:
        break
print(x)

import numpy as np
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_np = np.array(A)
B_np = np.array(B)

C_np = np.append(A_np,B_np)
C_np = np.sort(C_np)

x = 0
y = 0
for i in range(len(C_np)):
    if K >= x + C_np[i]:
        x += C_np[i]
        y += 1
    else:
        break
print(x)

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)

import numpy as np
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_np = np.array(A)
B_np = np.array(B)

C_np = np.append(A_np,B_np)
C_np = np.sort(C_np)
print(C_np)
x = 0
for i in range(len(C_np)):
    if K >= x + C_np[i]:
        x += C_np[i]
        y += 1
    else:
        break
print(y)

import numpy as np
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_np = np.array(A)
B_np = np.array(B)

y=0
for i in range(N+M):
    if K >= min(A_np[0],B_np[0]):
        if A_np[0] < B_np[0]:
            K -= A_np[0]
            np.delete(A_np,0)
            y+=1
        else:
            K -= B_np[0]
            np.delete(B_np,0)
            y+=1
print(y)

import numpy as np
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_np = np.array(A)
B_np = np.array(B)

C_np = np.append(A_np,B_np)
C_np = np.sort(C_np)

x = 0
for i in range(len(C_np)):
    if K >= x + C_np[i]:
        x += 1
    else:
        break
print(x)

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)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted