problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02623
u520843951
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s470363493', 's774894584']
[47296.0, 47336.0]
[190.0, 261.0]
[361, 361]
p02623
u521866787
2,000
1,048,576
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.
['n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\naindex=n+1\nbindex=m+1\nacumsum = [0]\nbcumsum = [0]\n\nab =0\nfor aa in range(n):\n ab += a[aa]\n acumsum.append(ab)# = ab\n if ab>k:\n aindex= aa\n break\n\nab =0\nfor bb in range(m):\n ab += b[bb]\n bcumsum.append(ab)\n if ab>k:\n bindex= bb\n break\n\n# print(acumsum,bcumsum)\nfrom bisect import bisect_left\nfor i in range(aindex):\n j = bisect_left(bcumsum, k-acumsum[i])\n # print(i,j)\n ans = max(ans, i+max(j,n))\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\naindex=n+1\nbindex=m+1\nacumsum = [0]\nbcumsum = [0]\n\nab =0\nfor aa in range(n):\n ab += a[aa]\n acumsum.append(ab)# = ab\n if ab>k:\n aindex= aa\n break\n\nab =0\nfor bb in range(m):\n ab += b[bb]\n bcumsum.append(ab)\n if ab>k:\n bindex= bb\n break\n\nj= m\nfor i in range(n+1):\n if acumsum[i] >k:\n break\n while bcumsum[j] > k-acumsum[i]:\n j -=1\n ans = max(ans, i+j)\n\nprint(ans)\n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\naindex=n\nbindex=m\nacumsum = [0]\nbcumsum = [0]\n\nab =0\nfor aa in range(n):\n ab += a[aa]\n acumsum.append(ab)# = ab\n if ab>k:\n aindex= aa\n break\n\nab =0\nfor bb in range(m):\n ab += b[bb]\n bcumsum.append(ab)\n if ab>k:\n bindex= bb\n break\n\nj= bindex\nfor i in range(aindex+1):\n if acumsum[i] >k:\n break\n while bcumsum[j] > k-acumsum[i]:\n j -=1\n ans = max(ans, i+j)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\naindex=n\nbindex=m\nacumsum = [0]\nbcumsum = [0]\n\nab =0\nfor aa in range(n):\n ab += a[aa]\n acumsum.append(ab)# = ab\n if ab>k:\n aindex= aa\n break\n\nab =0\nfor bb in range(m):\n ab += b[bb]\n bcumsum.append(ab)\n if ab>k:\n bindex= bb\n break\n\nj= bindex\nfor i in range(aindex+1):\n if acumsum[i] >k:\n break\n while bcumsum[j] > k-acumsum[i]:\n j -=1\n ans = max(ans, i+j)\n\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s130675317', 's181680859', 's929512153', 's988496408']
[42404.0, 40468.0, 40672.0, 40488.0]
[367.0, 305.0, 302.0, 309.0]
[531, 491, 484, 497]
p02623
u527299145
2,000
1,048,576
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.
['import numpy as np\nimport pandas as pd\n\n\nN, M, K = map(int, input().split())\nA = [n for n in input().split()]\nB = [n for n in input().split()]\n\nA = np.array(A)\nB = np.array(B)\n\nA = np.cumsum(A)\nB = np.cumsum(B)\n\nA1 = np.zeros((len(A),2))\nA1[:,0] = A\nA1[:,1] = np.arange(1,len(A)+1)\n\nB1 = np.zeros((len(B),2))\nB1[:,0] = B\nB1[:,1] = np.arange(1,len(B)+1)\n\nC1 = np.zeros((len(A)*len(B),2))\nlenB = len(B)\nfor i in range(len(A)):\n for j in range(len(B)):\n C1[lenB*i+j,:] = A1[i,:] + B1[j,:]\nC1 = pd.DataFrame(C1)\nC1 = C1[C1[0] <= K]\n\nprint(int(C1[1].max())\n', 'import numpy as np\n\nN, M, K = map(int, input().split())\nA = [int(n) for n in input().split()]\nB = [int(n) for n in input().split()]\n\nA = np.array(A)\nB = np.array(B)\n\nA0 = np.cumsum(A)\nB0 = np.cumsum(B)\n\nA1 = np.zeros((N,2))\nA1[:,0] = A0\nA1[:,1] = np.arange(1,N+1)\n\nB1 = np.zeros((M,2))\nB1[:,0] = B0\nB1[:,1] = np.arange(1,M+1)\n\nprint(A1)\n\nC1 = np.zeros((N*M,2))\nfor i in range(N):\n for j in range(M):\n C1[M*i+j,:] = A1[i,:] + B1[j,:]\nC2 = np.array([C[1] for C in C1 if C[0] <= K])\n\nif len(C2):\n print(int(C2.max()))\nelse:\n print(0)', 'import numpy as np\n\nN, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = [0] + list(map(int, input().split()))\n\nA = np.array(A).cumsum()\nB = np.array(B).cumsum()\n\nans = 0\nj = M\nfor i in range(N+1):\n if A[i] > K:\n break\n while B[j] > K - A[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s183114860', 's836419517', 's231280610']
[9100.0, 57436.0, 59756.0]
[24.0, 586.0, 531.0]
[562, 546, 335]
p02623
u531220228
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nsum_A = [0]\nfor i,a in enumerate(A, 1):\n tmp = sum_A[i-1] + a\n if tmp <= K:\n sum_A.append(tmp)\n mark_A = i\n else:\n break\n \nsum_B = [0]\nfor i,b in enumerate(B, 1):\n tmp = sum_B[i-1] + b\n if tmp <= K:\n sum_B.append(tmp)\n mark_B = i\n else:\n break\n \nans = 0\nj = M\n\nfor i,a in enumerate(sum_A):\n while sum_B[j] > K - a:\n j -= 1\n \n ans = max(ans, i+j)\n \nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nsum_A = [0]\nfor i,a in enumerate(A, 1):\n tmp = sum_A[i-1] + a\n if tmp <= K:\n sum_A.append(tmp)\n mark_A = i\n else:\n break\n \nsum_B = [0]\nfor i,b in enumerate(B, 1):\n tmp = sum_B[i-1] + b\n if tmp <= K:\n sum_B.append(tmp)\n mark_B = i\n else:\n break\n \nans = 0\nj = len(sum_B) - 1\n\nfor i,a in enumerate(sum_A):\n while sum_B[j] > K - a:\n j -= 1\n \n ans = max(ans, i+j)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s641282936', 's929923052']
[40376.0, 40492.0]
[324.0, 334.0]
[556, 569]
p02623
u531631168
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ni, j = 0, 0\ntime = 0\nwhile time <= k:\n print(i, j)\n if i < n and A[i] < B[j]:\n time += A[i]\n i += 1\n elif j < m:\n time += B[j]\n j += 1\n if i >= n and j >= m:\n break\nans = i + j\nif time > k:\n ans -= 1\nprint(ans)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nA_cum, B_cum = [0], [0]\nfor i, a in enumerate(A):\n A_cum.append(A_cum[i] + a)\nfor i in range(m):\n B_cum.append(B_cum[i] + B[i])\n\nans = 0\nbest = m\nfor i in range(n+1):\n a_time = A_cum[i]\n for j in range(best, -1, -1):\n if B_cum[j] <= k - a_time:\n ans = max(ans, i + j)\n break\n best = j\nprint(ans)']
['Runtime Error', 'Accepted']
['s352017094', 's797231458']
[40680.0, 47344.0]
[286.0, 328.0]
[368, 447]
p02623
u535171899
2,000
1,048,576
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.
['import bisect\nimport itertools\nn,m,k = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na_cum = list(itertools.accumulate(A))\n\nidx = 0\ncnt = 0\ntmp = 0\npost_idx = 0\nfor i in range(m):\n b = B[i]\n idx = bisect.bisect_left(A,b,lo=idx+1)\n A.insert(idx,b)\nprint(A)', 'import bisect\nimport itertools\nn,m,k = map(int,input().split())\nA = [0]+list(map(int,input().split()))\nB = [0]+list(map(int,input().split()))\n\n\na_cum = list(itertools.accumulate(A))\nb_cum = list(itertools.accumulate(B))\n\nans=0\n\n\n\nfor a_i,a in enumerate(a_cum):\n if a>k:\n break\n \n b_i = bisect.bisect_right(b_cum,k-a)-1\n ans = max(ans,a_i+b_i)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s040732077', 's769918366']
[41132.0, 47272.0]
[2207.0, 292.0]
[314, 595]
p02623
u537550206
2,000
1,048,576
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.
['from collections import deque\nn, m, k = map(int, input().split())\na = deque(list(map(int, input().split())))\nb = deque(list(map(int, input().split())))\n\ntime = 0\ncount = 0\nwhile len(a) > 0 or len(b) > 0:\n if len(a) == 0:\n book_b = b.popleft()\n time += book_b\n count += 1\n elif len(b) == 0:\n book_a = a.popleft()\n time += book_a\n count+= 1\n elif a[0] > b[0]:\n book_b = b.popleft()\n time += book_b\n count += 1\n elif a[0] == b[0]:\n if a[1] > b[1]:\n book_b = b.popleft()\n time += book_b\n count += 1\n else:\n book_a = a.popleft()\n time += book_a\n count += 1 \n else:\n book_a = a.popleft()\n time += a.popleft()\n count += 1\n if time > k:\n count -= 1\n break\n\n \nprint(count) \n\n \n', 'import bisect\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\n\nbook_a = [0] * (n + 1)\nfor i in range(n):\n book_a[i + 1] = book_a[i] + a[i]\n\nbook_b = [0] * (m + 1) \nfor j in range(m):\n book_b[j + 1] = book_b[j] + b[j]\ncount = 0\nfor read in range(n + 1):\n tmp = k - book_a[read]\n if tmp < 0:\n break\n read_b = bisect.bisect_right(book_b, tmp) -1\n count = max(count, read_b + read)\n\nprint(count)\n \n\n\n\n\n\n']
['Runtime Error', 'Accepted']
['s886181601', 's824382835']
[40064.0, 47464.0]
[256.0, 326.0]
[884, 488]
p02623
u538516600
2,000
1,048,576
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.
['s = list(map(int,input().split()))\nN = s[0]\nM = s[1]\nK = s[2]\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nasum = [0]\nbsum = [0]\napsum = 0\nbpsum = 0\nfor times in a:\n apsum += times\n asum.append(apsum)\nfor times in b:\n bpsum += times\n bsum.append(bpsum)\n\nnums = []\ni = 0\nj = M\nfor i in range(N+1):\n if asum[i]>K:\n pass\n else:\n while asum[i]+bsum[j] > K:\n print(i,j)\n j += -1\n nums.append(i+j)\nprint(max(nums))', 's = list(map(int,input().split()))\nN = s[0]\nM = s[1]\nK = s[2]\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nasum = [0]\nbsum = [0]\napsum = 0\nbpsum = 0\nfor times in a:\n apsum += times\n asum.append(apsum)\nfor times in b:\n bpsum += times\n bsum.append(bpsum)\nprint(asum)\nprint(bsum)\n\nnums = []\ni = 0\nj = M\nfor i in range(N+1):\n if asum[i]>K:\n pass\n else:\n while asum[i]+bsum[j] > K:\n print(i,j)\n j += -1\n nums.append(i+j)\nprint(max(nums))\nprint(nums)', 's = list(map(int,input().split()))\nN = s[0]\nM = s[1]\nK = s[2]\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nasum = [0]\nbsum = [0]\napsum = 0\nbpsum = 0\nfor times in a:\n apsum += times\n asum.append(apsum)\nfor times in b:\n bpsum += times\n bsum.append(bpsum)\n\nnums = []\ni = 0\nj = M\nfor i in range(N+1):\n if asum[i]>K:\n pass\n else:\n while asum[i]+bsum[j] > K:\n j += -1\n nums.append(i+j)\nprint(max(nums))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s072594938', 's862413896', 's690295031']
[50504.0, 54760.0, 50656.0]
[356.0, 421.0, 251.0]
[460, 496, 443]
p02623
u543016260
2,000
1,048,576
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.
['N, M, K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\nAsum=[0]\nBsum=[0]\n\nfor i in range(N):\n Asum.append(Asum[-1]+A[i])\n if Asum[i]>K:\n break\n \nfor i in range(M):\n Bsum.append(Bsum[-1]+B[i])\n if Bsum[i]>K:\n break\n \nm=0\nfor i in range(len(Asum)):\n for j in range(len(Bsum)):\n\n elif Asum[i]+Bsum[j]<=K and m<i+j:\n m=i+j\nprint(m)', 'N, M, K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\nAsum=[0]\nBsum=[0]\n\nfor i in range(N):\n Asum.append(Asum[-1]+A[i])\n \nfor i in range(M):\n Bsum.append(Bsum[-1]+B[i])\n \nm=0\nj=M\n\nfor i in range(len(Asum)):\n if Asum[i]>K:\n break\n elif Asum[i]+Bsum[j]<=K and m<i+j:\n m=i+j\n elif:\n j-=1\nprint(m)', 'N, M, K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\nAsum=[0]\nBsum=[0]\n\nfor i in range(N):\n Asum.append(Asum[-1]+A[i])\n if Asum[i]>K:\n break\n \nfor i in range(M):\n Bsum.append(Bsum[-1]+B[i])\n if Bsum[i]>K:\n break\n \nm=0\nfor i in range(len(Asum)):\n for j in range(len(Bsum)):\n\n elif Asum[i]+Bsum[j]<=K and m<i+j:\n m=i+j\nprint(m)\n ', 'N, M, K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\nAsum=[0]\nBsum=[0]\n\nfor i in range(N):\n Asum.append(Asum[-1]+A[i])\n \nfor i in range(M):\n Bsum.append(Bsum[-1]+B[i])\n \nm=0\nj=M\n\nfor i in range(len(Asum)):\n if Asum[i]>K:\n break\n elif Asum[i]+Bsum[j]<=K and m<i+j:\n m=i+j\n else:\n j-=1\nprint(m)', 'N, M, K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\nAsum=[0]\nBsum=[0]\n\nfor i in range(N):\n Asum.append(Asum[-1]+A[i])\n \nfor i in range(M):\n Bsum.append(Bsum[-1]+B[i])\n \nm=0\nj=M\n\nfor i in range(len(Asum)):\n if Asum[i]>K:\n break\n while Asum[i]+Bsum[j]>K:\n j-=1\n if m<i+j:\n m=i+j\n \nprint(m)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s236379506', 's324599196', 's459495906', 's811054118', 's654435280']
[8948.0, 9044.0, 8960.0, 47524.0, 47396.0]
[27.0, 27.0, 24.0, 252.0, 269.0]
[425, 389, 442, 389, 392]
p02623
u544865362
2,000
1,048,576
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.
['[n, m, k] = [int(x) for x in input().split()]\n\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nif sum(a)+sum(b) <= k:\n print(n+m)\n\n\nelse:\n if sum(a) < sum(b):\n small = a\n big = b\n else:\n small = b\n big = a\n\n # print(sum(small))\n\n if sum(small) == k:\n print(len(small))\n\n\n if sum(small) < k:\n count = 0\n while sum(small) < k:\n small.append(big.pop(0))\n count += 1\n \n print(len(small) + count)\n\n elif sum(small) > k:\n # print("here")\n while len(small) > 0 and sum(small) > k:\n small.pop(0)\n count = 0\n while len(small) > 0 and sum(small) <= k:\n small.append(big.pop(0))\n if sum(small) > k:\n small.pop()\n count += 1\n print(len(small))\n # print(small)\n\n \n\n\n \n# ans = 0\n# temp = 0\n\n# if temp+a[i] <= k:\n# temp+=a[i]\n# ans += 1\n\n# else:\n# break\n\n\n# if temp+b[i] <= k:\n# temp+=b[i]\n# ans += 1\n\n# else:\n# break\n\n# print(ans)\n\n\n# ans =0 \n\n\n# while k > 0 and len(b)>0 and len(a)>0:\n# if len(a) > 0 and a[0] <= b[0]:\n\n\n# ans += 1\n# a.pop(0)\n# else:\n# break\n\n# elif len(b) > 0 and b[0] <= a[0]:\n\n\n# ans += 1\n# b.pop(0)\n# else:\n# break\n\n\n# if len(b)>0:\n# while len(b)>0 and k >= b[0]:\n\n# ans += 1\n# b.pop(0)\n\n# elif len(a)>0:\n# while len(a)>0 and k >= a[0]:\n\n# ans += 1\n# a.pop(0)\n\n\n\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s722940322', 's903056987']
[41720.0, 47684.0]
[2206.0, 290.0]
[1795, 364]
p02623
u547231875
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\na.append(a[i] + A[i])\nfor i in range(M):\nb.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\nif a[i] > K:\nbreak\nwhile b[j] > K - a[i]:\nj -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s572197688', 's355573025']
[8984.0, 47372.0]
[24.0, 299.0]
[324, 360]
p02623
u548272916
2,000
1,048,576
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.
['n,m,k = map(int,input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA = [0]\nB = [0]\n\nfor i in range(len(a)):\n A.append(a[i] + A[i])\nfor i in range(len(b)):\n B.append(b[i] + B[i])\n\nloop = False\nnum = 0\nx = m \n\nfor i in range(1,len(A)):\n while A[i] + B[x] > k and x > 0 and A[i] <= k:\n x -= 1\n loop = True\n \n if loop:\n num = max(num, i + x)\n\n\nprint(num)\n\n\n', 'n,m,k = map(int,input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA,B = [0],[0]\n \nfor i in range(n):\n A.append(a[i] + A[i])\nfor i in range(m):\n B.append(b[i] + B[i])\n \nnum,x = 0,m\n \nfor i in range(len(a)-1):\n if A[i] > k:\n break\n while A[i] + B[x] > k:\n x -= 1\n num = max(num, i + x)\n \nprint(num)\n \n ', 'n,m,k = map(int,input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA,B = [0],[0]\n \nfor i in range(n):\n A.append(a[i] + A[i])\nfor i in range(m):\n B.append(b[i] + B[i])\n \nnum,x = 0,m\n \nfor i in range(len(A)):\n if A[i] > k:\n break\n while A[i] + B[x] > k:\n x -= 1\n num = max(num, i + x)\n \nprint(num)\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s209533395', 's296728107', 's770235370']
[47512.0, 47360.0, 47448.0]
[321.0, 293.0, 283.0]
[407, 351, 347]
p02623
u552083508
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nif N<M:\n for i in range(N,M+1):\n A.append(pow(10,10))\nif N>M:\n for i in range(M,N+1):\n B.append(pow(10,10))\nA.append(pow(10,10))\nB.append(pow(10,10))\nt=0\ncount=0\nA_count=0\nB_count=0\nwhile t<=K:\n if A[A_count]<=B[B_count]:\n t+=A[A_count]\n A_count+=1\n count+=1\n else:\n t+=B[B_count]\n B_count+=1\n count+=1\n print(t)\nprint(count-1)', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na=[0]\nb=[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\n#print(a)\n#print(b)\n\nans=0\nj=M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n #print(i,j)\n ans=max(ans,i+j)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s561644264', 's695257701']
[40448.0, 47496.0]
[324.0, 283.0]
[496, 361]
p02623
u555767343
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nimport numpy as np\nA_cumsum = np.cumsum(A)\nB_cumsum = np.cumsum(B)\n\n\n\nlenA = len(A)\nlenB = len(B)\n\nif lenA < lenB:\n A_cumsum = np.concatenate([A_cumsum, [max(B_cumsum)+1]])\nelse:\n B_cumsum = np.concatenate([B_cumsum, [max(A_cumsum)+1]])\n\nprint(A_cumsum)\nprint(B_cumsum)\n\n\ni = 0\nj = 0\nt = 0\nans = 0\nwhile i < lenA or j < lenB:\n if A_cumsum[i] < B_cumsum[j]:\n ans += 1\n t += A[i]\n i += 1\n else:\n ans += 1\n t += B[j]\n j += 1\n# print(ans, t)\n# print(i,j)\n if t > K:\n ans -= 1\n break\nprint(ans)', "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nimport numpy as np\nA0 = [0] + A\nB0 = [0] + B\nAA = np.cumsum(A0)\nBB = np.cumsum(B0)\n\nans = 0\njmax = M\nfor i in range(0, N+1):\n a = AA[i]\n if a > K:\n break\n for j in range(jmax, -1, -1):\n b = BB[j]\n# print(a, b)\n if a + b <= K:\n ans = max(ans, i+j)\n# print('ok')\n break\n jmax = j\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s053200583', 's244491606']
[47204.0, 50288.0]
[432.0, 572.0]
[733, 470]
p02623
u557792847
2,000
1,048,576
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.
['import sys\nimport numpy as np\nimport math\nimport collections\nfrom collections import deque \nfrom functools import reduce\n\n# input = sys.stdin.readline\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na_t, b_t = [0], [0]\nfor i in range(n):\n a_t.append(a_t[i] + a[i])\nfor i in range(m):\n b_t.append(b_t[i] + b[i])\nans = 0\nj = m\nfor i in range(n+1):\n if (a[i] > k):\n break\n while(a_t[i] + b_t[j] > k):\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n\n', 'import sys\nimport numpy as np\nimport math\nimport collections\nfrom collections import deque \nfrom functools import reduce\n\n# input = sys.stdin.readline\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nb_max = 0\nbi_max = 0\nfor bi in b:\n if b_max > k:\n b_max -= bi\n bi_max -= 1\n break\n b_max += bi\n bi_max += 1\nti = bi_max\nt_max = 0\nai_max = 0\na_max = 0\nfor ai in a:\n if a_max + ai > k:\n break\n ai_max += 1\n a_max += ai\n for j in range(bi_max, -1, -1):\n if ai_max + bi_max <= k:\n if ai_max + bi_max > ti:\n ti = ai_max + bi_max\n break\n bi_max -= 1\n if ai_max + bi_max > ti:\n ti = ai_max + bi_max\nprint(ti) \n\n\n\n', 'import sys\nimport numpy as np\nimport math\nimport collections\nfrom collections import deque \nfrom functools import reduce\n\n# input = sys.stdin.readline\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nb_max = 0\nbi_max = 0\nfor bi in b:\n if b_max > k:\n b_max -= bi\n bi_max -= 1\n break\n b_max += bi\n bi_max += 1\nti = bi_max\nt_max = 0\nai_max = 0\na_max = 0\nfor ai in a:\n if a_max + ai > k:\n break\n ai_max += 1\n a_max += ai\n for j in range(bi_max, 0, -1):\n if ai_max + bi_max <= k:\n if ai_max + bi_max > ti:\n ti = ai_max + bi_max\n break\n bi_max -= 1\n if ai_max + bi_max > ti:\n ti = ai_max + bi_max\nprint(ti) \n\n\n\n', 'import sys\nimport numpy as np\nimport math\nimport collections\nfrom collections import deque \nfrom functools import reduce\n\n# input = sys.stdin.readline\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nb_max = 0\nbi_max = 0\nfor bi in b:\n if b_max > k:\n b_max -= bi\n bi_max -= 1\n break\n b_max += bi\n bi_max += 1\nti = bi_max\nt_max = 0\nai_max = 0\na_max = 0\nfor ai in a:\n if a_max + ai > k:\n break\n ai_max += 1\n a_max += ai\n for j in range(bi_max, 0, -1):\n if ai_max + bi_max <= k:\n if ai_max + bi_max > ti:\n ti = ai_max + bi_max\n break\n bi_max -= 1\nprint(ti) \n\n\n\n', 'import sys\nimport numpy as np\nimport math\nimport collections\nfrom collections import deque \nfrom functools import reduce\n\n# input = sys.stdin.readline\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na_t, b_t = [0], [0]\nfor i in range(n):\n a_t.append(a_t[i] + a[i])\nfor i in range(m):\n b_t.append(b_t[i] + b[i])\nans = 0\nj = m\nfor i in range(n+1):\n if (a_t[i] > k):\n break\n while(a_t[i] + b_t[j] > k):\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s052046127', 's490883949', 's685276286', 's868876112', 's613041467']
[65536.0, 58680.0, 58592.0, 58256.0, 65020.0]
[405.0, 376.0, 370.0, 368.0, 371.0]
[530, 778, 777, 719, 532]
p02623
u565791439
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\ncount=sum(B)\na=0\np=0\nfor i in range(N):\n while count>K:\n count-=B[M-1]\n M-=1\n if i!=N-1:\n count+=A[i]\n a+=A[i]\n p=max(p,i+M+1)\n if a>K:\n break\nprint(p)', "N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\ncount=sum(B)\na=0\nai = 0\np=0\nfor i in range(N):\n print('s1:',count,ai,M)\n while count>K:\n count-=B[M-1]\n M-=1\n print('s2:',count,ai,M)\n count+=A[i]\n a+=A[i]\n ai+=1\n print('s3:',count,ai,M)\n if count <= K:\n p=max(p,ai+M)\n print('s4',count,p,ai,M)\n if a>K:\n break\nprint(p)\n", "N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\ncount = 0\nbi = 0\nfor j in range(M):\n if count + B[j] > K:\n break\n count += B[j]\n bi += 1\na=0\nai = 0\np = bi\nfor i in range(N):\n #ep('s1:',count,ai,bi)\n if a + A[i] > K:\n break;\n a += A[i]\n count += A[i]\n ai+=1\n #ep('s2:',count,ai,M)\n \n while count>K:\n count-=B[bi-1]\n bi-=1\n #ep('s3:',count,ai,M)\n if count <= K:\n p=max(p,ai+bi)\n #ep('s4',count,p,ai,M)\nprint(p)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s391508663', 's819063814', 's084063197']
[40620.0, 44976.0, 40592.0]
[244.0, 1050.0, 302.0]
[295, 425, 535]
p02623
u567225946
2,000
1,048,576
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.
['from bisect import bisect_left,bisect_right\nn,m,k=map(int,input().split())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\nfor i in range(1,n):\n arr1[i]=arr1[i]+arr1[i-1]\nfor i in range(1,m):\n arr2[i]=arr2[i]+arr2[i-1]\nma=0\nfor i in range(n):\n c=k-arr1[i]\n ind=bisect_right(arr2,c)\n if arr2[ind]<=c:\n ma=max(ma,ind+i+1)\nprint(ma)', 'from bisect import bisect_left,bisect_right\nn,m,k=map(int,input().split())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\nfor i in range(1,n):\n arr1[i]=arr1[i]+arr1[i-1]\nfor i in range(1,m):\n arr2[i]=arr2[i]+arr2[i-1]\nma=0\nfor i in range(n):\n if arr1[i]<=k:\n ma=max(ma,bisect_right(arr2,k-arr1[i])+i+1)\nfor i in range(m):\n if arr2[i]<=k:\n ma=max(ma,bisect_right(arr1,k-arr2[i])+i+1)\nprint(ma)']
['Runtime Error', 'Accepted']
['s755835405', 's091948526']
[40544.0, 40580.0]
[286.0, 448.0]
[375, 443]
p02623
u570039786
2,000
1,048,576
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.
['import sys \nimport numpy as np\n\nread = sys.stdin.buffer.read \nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines \n\nN, M, K = map(int, readline().split())\nA = np.array(readline().split(), np.int64)\nB = np.array(readline().split(), np.int64)\n\nAcum = np.zeros(N+1, np.int64)\nAcum[1:] = np.cumsum(A)\nBcum = np.zeros(M+1, np.int64)\nBcum[1:] = np.cumsum(B)\n\nprint(Bcum)', "import sys \nimport numpy as np\nimport bisect as bs \n\ndef binarySearch_canread(data, target):\n if len(data) == 0:\n return None\n if len(data) == 1:\n return data[0]\n\n \n if target > max(data):\n return len(data)\n elif target < min(data):\n return 0\n\n min_diff = float('inf')\n imin = 0\n imax = len(data) - 1\n closest_num = None\n\n while imin <= imax:\n imid = imin + (imax - imin) // 2\n\n if imid + 1 < len(data):\n min_diff_right = abs(data[imid + 1] - target)\n if imid > 0:\n min_diff_left = abs(data[imid - 1] - target)\n\n if min_diff_left < min_diff:\n min_diff = min_diff_left \n closest_num = data[imid - 1]\n if min_diff_right < min_diff:\n min_diff = min_diff_right\n closest_num = data[imid + 1]\n\n if data[imid] < target:\n imin = imid + 1\n elif data[imid] > target:\n imax = imid - 1\n else:\n return list(data).index(data[imid]) + 1 # data[imid]\n\n \n differ = target - closest_num\n can_read = None\n if differ > 0: \n can_read = max([i for i, x in enumerate(data) if x == closest_num]) + 1\n elif differ < 0: \n can_read = min([i for i, x in enumerate(data) if x == closest_num])\n\n\n\n return can_read\n\nif __name__ == '__main__':\n read = sys.stdin.buffer.read \n readline = sys.stdin.buffer.readline\n readlines = sys.stdin.buffer.readlines \n\n N, M, K = map(int, readline().split())\n A = np.array(readline().split(), np.int64)\n B = np.array(readline().split(), np.int64)\n\n Acum = np.zeros(N+1, np.int64)\n Acum[1:] = np.cumsum(A)\n Bcum = np.zeros(M+1, np.int64)\n Bcum[1:] = np.cumsum(B)\n\n \n max_read = 0\n # O(N * logN)\n for i, cumNum in enumerate(Acum): \n if cumNum <= K:\n limit = K - cumNum\n # O(logN)\n can_reading = i + bs.bisect_right(Bcum[1:], limit)\n if (max_read < can_reading):\n max_read = can_reading\n\n print(max_read)"]
['Wrong Answer', 'Accepted']
['s671946594', 's788213841']
[42864.0, 42872.0]
[187.0, 657.0]
[388, 2324]
p02623
u570155187
2,000
1,048,576
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.
['n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\na.append(10**10)\nb.append(10**11)\n\nprint(n,m,k,a,b)\n\ni = 0\nj = 0\nt = 0\ncnt = 0\nwhile t+a[i] <= k or t+b[j] <= k:\n if a[i] < b[j]:\n t += a[i]\n i += 1\n cnt += 1\n else:\n t += b[j]\n j += 1\n cnt += 1\nprint(cnt)', 'from itertools import accumulate\nimport bisect\n\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\na_acc = [0] + list(accumulate(a))\nb_acc = list(accumulate(b))\n\nans = 0\nfor i in range(n + 1):\n rem = k - a_acc[i]\n if rem < 0:\n break\n\n j = bisect.bisect_right(b_acc, rem)\n ans = max(ans, i + j)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s056843756', 's407785388']
[40600.0, 48996.0]
[264.0, 276.0]
[329, 377]
p02623
u572425901
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\nA = [0] + list(map(int,input().split()))\nB = [0] + list(map(int,input().split()))\n \nfor i in range(2,n):\n A[i] += A[i-1]\nfor i in range(1,m):\n B[i] += B[i-1]\nj = m\nans = 0\nfor i in range(n+1):\n if A[i] > k:\n break \n while B[j] > k-A[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)', 'n, m, k = map(int, input().split())\nA = [0] + list(map(int,input().split()))\nB = [0] + list(map(int,input().split()))\n \nfor i in range(2,n+1):\n A[i] += A[i-1]\nfor i in range(2,m+1):\n B[i] += B[i-1]\n\nj = m\nans = 0\nfor i in range(n+1):\n if A[i] > k:\n break \n while B[j] > k-A[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s381116772', 's308755525']
[39924.0, 39876.0]
[276.0, 285.0]
[341, 346]
p02623
u576432509
2,000
1,048,576
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.
['n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nfrom itertools import accumulate\naa=list(accumulate(a))\nbb=list(accumulate(b))\n\nfrom bisect import bisect_left,bisect\n\nkmax=0\nfor i in range(n):\n if k<aa[i]:\n break\n kk=k-aa[i]\n k2=bisect(bb,kk)\n print(i,k2)\n kmax=max(kmax,k2+i+1)\n\nprint(kmax)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nfrom itertools import accumulate\naa=list(accumulate(a))\nbb=list(accumulate(b))\n\nfrom bisect import bisect_left,bisect\n\nkmax=0\nfor i in range(n):\n if k<=aa[i]:\n break\n kk=k-aa[i]\n k2=bisect(bb,kk)\n print(i,k2)\n kmax=max(kmax,k2+i+1)\n\nprint(kmax)\n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nfrom itertools import accumulate\naa=[0]+list(accumulate(a))\nbb=[0]+list(accumulate(b))\n\nfrom bisect import bisect_left,bisect\n\nkmax=0\nfor i in range(n+1):\n if k<aa[i]:\n break\n kk=k-aa[i]\n k2=bisect(bb,kk)-1\n# print(i,k2,aa[i],bb[k2])\n kmax=max(kmax,k2+i)\n\nprint(kmax)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s366813085', 's889127771', 's471687369']
[47292.0, 47456.0, 50688.0]
[407.0, 389.0, 292.0]
[363, 365, 387]
p02623
u580273604
2,000
1,048,576
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.
['import numpy as np\nimport bisect\nN,M,K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\nif A[0]>K and B[0]>K:print(0);exit()\n\nAsum=[0]\nfor i in range(N):\n if Asum[-1]+A[i]<=K:\n Asum.append(Asum[-1]+A[i]) \n\nBsum=[0]\nfor j in range(M):\n if Bsum[-1]+B[j]<=K:\n Bsum.append(Bsum[-1]+B[j])\nAAsum=[]\nfor i in range(N):\n AAsum.append(K-Asum[i])\n\nprint(Asum)\nprint(AAsum)\nprint(Bsum)\nexit()\nC=[]\nfor i in range(len(Asum)):\n C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)\n\n#print(Asum)\n#print(AAsum)\n#print(Bsum)\n#print(C)\nprint(max(C))', 'import numpy as np\nN,M,K= map(int, input().split())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\n\nAsum=[0]*(N+1)\nsum=0;i=0\nAsum[0]=0\nwhile sum<K and i+1<=N:\n sum+=A[i]\n if sum<K:Asum[i+1]=A[i]+Asum[i]\n i+=1\nAmax=i-1\n\nBsum=[0]*(M+1)\nsum=0;i=0\nBsum[0]=0\nwhile sum<K and i+1<=M:\n sum+=B[i]\n if sum<K:Bsum[i+1]=B[i]+Bsum[i] \n i+=1\nBmax=i-1\n\nMax=0;X=0;Y=0\n\nfor i in range(Amax,N+1):\n for j in range(1,M+1):\n if Asum[i]!=0 and Max<=Asum[i]+Bsum[j] and Asum[i]+Bsum[j]<=K:\n Max=Asum[i]+Bsum[j]\n X=i;Y=j\n else:continue\nMax=0;XX=0;YY=0\nfor i in range(1,N+1):\n for j in range(Bmax,M+1):\n if Bsum[j]!=0 and Max<=Asum[i]+Bsum[j] and Asum[i]+Bsum[j]<=K:\n Max=Asum[i]+Bsum[j]\n XX=i;YY=j\n else:continue\n\n# else:Csum[i*(Bmax+1)+j]=Asum[i]+Bsum[j]\n#print(Max)\n\n\nif A[0]>K and B[0]>K:\n print(0);exit()\nprint(max(X+Y,XX+YY))', 'import numpy as np\nimport bisect\nN,M,K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\nif A[0]>K and B[0]>K:print(0);exit()\n\nAsum=[0]\nfor i in range(N):\n if Asum[-1]+A[i]<=K:\n Asum.append(Asum[-1]+A[i]) \n else:break\nBsum=[0]\nfor j in range(M):\n if Bsum[-1]+B[j]<=K:\n Bsum.append(Bsum[-1]+B[j])\n else:break\n\nC=[]\nfor i in range(len(Asum)):\n C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)\nprint(max(C))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s567128710', 's889293249', 's803895544']
[71408.0, 59236.0, 67396.0]
[393.0, 2207.0, 435.0]
[580, 962, 456]
p02623
u582803594
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \nv,j=0,M\n\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n v=max(b,i+j)\n\nprint(v)\n \n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \nv,j=0,M\n\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n v=max(v,i+j)\n\nprint(v)\n \n']
['Runtime Error', 'Accepted']
['s216051841', 's724010886']
[47484.0, 47548.0]
[219.0, 281.0]
[331, 331]
p02623
u584083135
2,000
1,048,576
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.
['N, M, K = [int(x) for x in input().strip().split()]\nA = [int(x) for x in input().strip().split()]\nB = [int(x) for x in input().strip().split()]\ni = j = 0\nct = 0\nwhile k > 0: \n if i < N: \n if A[i] < B[j] and k-A[i] >= 0: \n ct +=1\n k -= A[i]\n i += 1\n continue\n if j < M: \n if k-B[j] >= 0: \n ct +=1\n k -= B[j]\n j +=1\n else: \n break\n else: \n break\nprint(ct)', 'N, M, K = [int(x) for x in input().strip().split()]\nA = [int(x) for x in input().strip().split()]\nB = [int(x) for x in input().strip().split()]\ni = j = 0\nct = 0\nwhile k > 0: \n if A[i] < B[j]: \n k -= A[i]\n i +=1\n else: \n k -= B[j]\n j +=1\n ct += 1\nprint(ct)\n ', 'N, M, K = [int(x) for x in input().strip().split()]\nA = [int(x) for x in input().strip().split()]\nB = [int(x) for x in input().strip().split()]\ni = j = 0\nct = 0\nwhile k> 0: \n if A[i] < B[j] and k-A[i] > 0: \n k -= A[i]\n i +=1\n ct +=1\n elif k-B[j] > 0: \n k -= B[j]\n j +=1\n \tct += 1\nprint(ct)', 'Source Code \n\nCopy\nCopy\nN, M, K = [int(x) for x in input().strip().split()]\nA = [int(x) for x in input().strip().split()]\nB = [int(x) for x in input().strip().split()]\ni = j = 0\nct = 0\nwhile k > 0: \n if i < N: \n if A[i] < B[j] and k-A[i] >= 0: \n ct +=1\n k -= A[i]\n i += 1\n continue\n if j < M: \n if k-B[j] >= 0: \n ct +=1\n k -= B[j]\n j +=1\n else: \n break\n else: \n break\nprint(ct)\nprint(ct)', 'N, M, K = [int(x) for x in input().strip().split()]\nA = [int(x) for x in input().strip().split()]\nB = [int(x) for x in input().strip().split()]\ni = j = 0\nct = 0\nwhile k > 0: \n if A[i] < B[j] and k - A[i] > 0: \n k -= A[i]\n i +=1\n elif k - B[j] > 0: \n k -= B[j]\n j +=1\n ct += 1\nprint(ct)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n \na, b = [0], [0]\nfor i in range(N):\n\ta.append(a[i]+A[i])\nfor i in range(M):\n\tb.append(b[i]+B[i])\n\t\nans, j = 0, M\nfor i in range(N+1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i+j)\n\t\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s061233627', 's241583960', 's360931843', 's523841644', 's730981377', 's195932782']
[40588.0, 40532.0, 8996.0, 8980.0, 40692.0, 47268.0]
[128.0, 127.0, 28.0, 25.0, 125.0, 307.0]
[408, 275, 307, 442, 300, 331]
p02623
u589257616
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\nans = max(ans, i + j)\n\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s388627847', 's776935582']
[47300.0, 47528.0]
[244.0, 283.0]
[338, 346]
p02623
u591143370
2,000
1,048,576
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.
['import bisect\nN,M,K = map(int, input().split())\nA= list(map(int, input().split()))\nB = list(map(int, input().split()))\nfor i in range(1,len(A)):\n A[i]+=A[i-1]\nfor i in range(1,len(B)):\n B[i]+=B[i-1]\nhonn=0\nfor i in range(len(A)):\n s=K-A[i]\n a=bisect.bisect(B,s)\n print(s)\n if i+1+a>honn:\n honn=i+1+a\nprint(honn)', 'import bisect\nN,M,K = map(int, input().split())\nA= list(map(int, input().split()))\nB = list(map(int, input().split()))\nfor i in range(1,len(A)):\n A[i]+=A[i-1]\nfor i in range(1,len(B)):\n B[i]+=B[i-1]\n\nhonn=bisect.bisect(B,K)\nprint(honn)\nfor i in range(len(A)):\n s=K-A[i]\n if s>=0:\n \n a=bisect.bisect(B,s)\n #print(s)\n if i+1+a>honn:\n honn=i+1+a\nprint(honn)', 'import bisect\nN,M,K = map(int, input().split())\nA= list(map(int, input().split()))\nB = list(map(int, input().split()))\nfor i in range(1,len(A)):\n A[i]+=A[i-1]\nfor i in range(1,len(B)):\n B[i]+=B[i-1]\nhonn=a=bisect.bisect(B,K)\nfor i in range(len(A)):\n s=K-A[i]\n if s>=0:\n a=bisect.bisect(B,s)\n if i+1+a>honn:\n honn=i+1+a\nprint(honn)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s415068903', 's941278589', 's438546475']
[40608.0, 40672.0, 40376.0]
[370.0, 294.0, 291.0]
[336, 405, 367]
p02623
u601159375
2,000
1,048,576
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.
["import itertools\n\nnumOfA,numOfB,target = map(int, input().split())\n\ntimetoreadA = list(map(int,input().split()))\ntimetoreadB = list(map(int,input().split()))\n\ntimetoreadAacc = list(itertools.accumulate(timetoreadA))\nbooknumifonlyA = 0\ntimeifonlyA = 0\nfor time in timetoreadAacc:\n\tif target < time:\n\t\tbreak\n\tbooknumifonlyA += 1\n\ttimeifonlyA = time\n\ntime = timeifonlyA\nbookcanbereadatA = booknumifonlyA\nbookcanberead = [bookcanbereadatA]\n\nfor bookcanbereadatB in range(numOfB):\n\tprint(f'time {time + timetoreadB[bookcanbereadatB]}, {bookcanbereadatA} {bookcanbereadatB}')\n\tif time + timetoreadB[bookcanbereadatB] <= target:\n\t\tbookcanberead.append(bookcanbereadatA + bookcanbereadatB + 1)\n\t\ttime = time + timetoreadB[bookcanbereadatB]\n\telse:\n\t\twhile time + timetoreadB[bookcanbereadatB] > target and bookcanbereadatA > 1:\n\t\t\tbookcanbereadatA -= 1\n\t\t\ttime = time - timetoreadA[bookcanbereadatA-1]\n\nprint(max(bookcanberead))", 'import itertools\n\nnumOfA,numOfB,target = map(int, input().split())\n\ntimetoreadA = list(map(int,input().split()))\ntimetoreadB = list(map(int,input().split()))\n\ntimetoreadAacc = list(itertools.accumulate(timetoreadA))\nbooknumifonlyA = 0\ntimeifonlyA = 0\nfor time in timetoreadAacc:\n\tif target < time:\n\t\tbreak\n\tbooknumifonlyA += 1\n\ttimeifonlyA = time\n\ntime = timeifonlyA\nbookcanbereadatA = booknumifonlyA\nbookcanberead = [bookcanbereadatA]\n\nfor bookcanbereadatB in range(numOfB):\n\tif newtime := time + timetoreadB[bookcanbereadatB] <= target:\n\t\tbookcanberead.append(bookcanbereadatA + bookcanbereadatB + 1)\n\t\ttime = newtime\n\telse:\n\t\twhile newtime > target and bookcanbereadatA > 1:\n\t\t\tbookcanbereadatA -= 1\n\t\t\tnewtime = newtime - timetoreadA[bookcanbereadatA-1]\n\t\ttime = newtime\n\nprint(bookcanberead)', 'import itertools\n\nnumOfA,numOfB,target = map(int, input().split())\n\ntimetoreadA = list(map(int,input().split()))\ntimetoreadB = list(map(int,input().split()))\n\ntimetoreadAacc = list(itertools.accumulate(timetoreadA))\n\nbooknumonlyA = 0\ntotaltime = 0\nfor time in timetoreadAacc:\n\tif target < time:\n\t\tbreak\n\tbooknumonlyA += 1\n\ttotaltime = time\n\nbookreadA = booknumonlyA\nbookread = [bookreadA]\n\nfor posB in range(numOfB):\n\tbookreadB = posB + 1\n\tnewtime = totaltime + timetoreadB[posB]\n\tif newtime <= target:\n\t\tbookread.append(bookreadA + bookreadB)\n\t\ttotaltime = newtime\n\telse:\n\t\twhile newtime > target and bookreadA > 0:\n\t\t\tbookreadA -= 1\n\t\t\tnewtime = newtime - timetoreadA[bookreadA]\n\n\t\tif newtime <= target:\n\t\t\tbookread.append(bookreadA + bookreadB)\n\n\t\ttotaltime = newtime\n\nprint(bookread)', 'import itertools\n\nnumOfA,numOfB,target = map(int, input().split())\n\ntimetoreadA = list(map(int,input().split()))\ntimetoreadB = list(map(int,input().split()))\n\ntimetoreadAacc = list(itertools.accumulate(timetoreadA))\nbooknumifonlyA = 0\ntimeifonlyA = 0\nfor time in timetoreadAacc:\n\tif target < time:\n\t\tbreak\n\tbooknumifonlyA += 1\n\ttimeifonlyA = time\n\ntime = timeifonlyA\nbookcanbereadatA = booknumifonlyA\nbookcanberead = [bookcanbereadatA]\n\nfor bookcanbereadatB in range(numOfB):\n\tif newtime := time + timetoreadB[bookcanbereadatB] <= target:\n\t\tbookcanberead.append(bookcanbereadatA + bookcanbereadatB + 1)\n\t\ttime = newtime\n\telse:\n\t\twhile newtime > target and bookcanbereadatA > 1:\n\t\t\tbookcanbereadatA -= 1\n\t\t\tnewtime = newtime - timetoreadA[bookcanbereadatA-1]\n\t\ttime = newtime\n\nprint(max(bookcanberead))', 'import itertools\n\nnumOfA,numOfB,target = map(int, input().split())\n\ntimetoreadA = list(map(int,input().split()))\ntimetoreadB = list(map(int,input().split()))\n\ntimetoreadAacc = list(itertools.accumulate(timetoreadA))\n\nbooknumonlyA = 0\ntotaltime = 0\nfor time in timetoreadAacc:\n\tif target < time:\n\t\tbreak\n\tbooknumonlyA += 1\n\ttotaltime = time\n\nbookreadA = booknumonlyA\nbookread = [bookreadA]\n\nfor posB in range(numOfB):\n\tbookreadB = posB + 1\n\tnewtime = totaltime + timetoreadB[posB]\n\tif newtime <= target:\n\t\tbookread.append(bookreadA + bookreadB)\n\t\ttotaltime = newtime\n\telse:\n\t\twhile newtime > target and bookreadA > 0:\n\t\t\tbookreadA -= 1\n\t\t\tnewtime = newtime - timetoreadA[bookreadA]\n\n\t\tif newtime <= target:\n\t\t\tbookread.append(bookreadA + bookreadB)\n\n\t\ttotaltime = newtime\n\nprint(max(bookread))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s253213161', 's409644613', 's834785737', 's885128028', 's739741972']
[41528.0, 44968.0, 44420.0, 43252.0, 41732.0]
[365.0, 209.0, 272.0, 196.0, 244.0]
[919, 796, 787, 801, 792]
p02623
u602773379
2,000
1,048,576
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.
['n,m,k=input2()\nA=input_array()\nB=input_array()\n\nca=0\ncb=0\ncount=0\nSUM=0\nfor i in range(10**5):\n\tif A[ca]<=B[cb]:\n\t\tSUM+=A[ca]\n\t\tca+=1\n\telse:\n\t\tSUM+=B[cb]\n\t\tcb+=1\n\n\tif SUM >=k:\n\t\tbreak\n\telse:\n\t\tcount+=1\nprint(count)', '\ndef input2():\n\treturn map(int,input().split())\n \nn,m,k=input2()\nA=input_array()\nB=input_array()\n\nca=0\ncb=0\ncount=0\nSUM=0\nfor i in range(n+m):\n\tif ca >= n:\n\t\tSUM+=B[cb]\n\t\tcb+=1\n\telif cb >= m:\n\t\tSUM+=A[ca]\n\t\tca+=1\n\telif A[ca]<=B[cb]:\n\t\tSUM+=A[ca]\n\t\tca+=1\n\telse:\n\t\tSUM+=B[cb]\n\t\tcb+=1\n\n\tif SUM >k:\n\t\tbreak\n\telse:\n\t\tcount+=1\nprint(count)', '\ndef input2():\n\treturn map(int,input().split())\n\n\ndef input_array():\n\treturn list(map(int,input().split()))\n \nn,m,k=input2()\nA=input_array()\nB=input_array()\nacc_A=[0]\nacc_B=[0]\n\nfor i in range(n):\n\tacc_A.append(A[i]+acc_A[i])\nfor i in range(m):\n\tacc_B.append(B[i]+acc_B[i])\n\nans=0\ntmp_m=m\nfor i in range(n+1):\n\tif acc_A[i]>k:\n\t\tbreak\n\tfor j in range(tmp_m,-1,-1):\n\t\tif acc_B[j]<=k-acc_A[i]:\n\t\t\tans=max(i+j,ans)\n\t\t\ttmp_m=j \n\t\t\tbreak\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s080054311', 's717941484', 's596027864']
[9036.0, 9228.0, 48840.0]
[28.0, 25.0, 363.0]
[214, 357, 533]
p02623
u605880635
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i]+A[i])\n\nfor i in range(M):\n b.append(b[i]+B[i])\n\n#print(a)\n#print(b)\n \nans =0\nj = M\n\nfor i in range(N+1):\n if a[i]>k:\n break\n \n while b[j]+a[i] > K :\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i]+A[i])\n if a[i]+A[i]>K:\n break\n\nfor i in range(M):\n b.append(b[i]+B[i])\n\n#print(a)\n#print(b)\n \nans =0\nj = M\n\nfor i in range(N+1):\n if a[i]>K:\n break\n \n while b[j]+a[i] > K :\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n\n']
['Runtime Error', 'Accepted']
['s135798788', 's378294597']
[47416.0, 40776.0]
[189.0, 321.0]
[385, 419]
p02623
u607563136
2,000
1,048,576
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.
['n, m, k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\na[0:0]=[0]\nb[0:0]=[0]\n\nans, j = 0, m\n\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)', 'n, m, k = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na, b = [0],[0]\n\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\n\nans, j = 0, m\n\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s478370315', 's361363508']
[40332.0, 47368.0]
[211.0, 287.0]
[277, 362]
p02623
u607709109
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nb_li = [0]\nb_ = 0\n\nfor B_ in B:\n b_ = b_ + B_\n b_li.append(b_)\n\nbook_max = 0\nbook_cnt_a = 0\nbook_cnt_ab = 0\na_ = 0\nbook_cnt_ab = M\n\nfor i in range(N+1):\n while (b_li[book_cnt_ab-1] + a_) > K:\n book_cnt_ab = book_cnt_ab - 1\n if book_cnt_ab == 0: break\n if (book_max <= book_cnt_ab + book_cnt_a):\n book_max = book_cnt_ab + book_cnt_a\n book_cnt_a = book_cnt_a + 1\n if i >= N: break\n a_ = a_ + A[i]\n\nprint(book_max)\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nbook_max = 0\nbook_cnt = 0\n\nAsum = 0\nfor ia in range(N+1):\n Bsum = 0\n for ib in range(M+1):\n if K < (Asum + Bsum): break\n book_cnt = book_cnt + 1\n if book_max < (book_cnt - 0):\n book_max = book_cnt\n if ib == M: break\n Bsum = Bsum + B[ib]\n book_cnt = ia + 1\n if book_max < (book_cnt - 0):\n book_max = book_cnt\n if ia == N: break\n Asum = Asum + A[ia]\n\nprint(book_max)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na_li = [0]\na_ = 0\nb_li = [0]\nb_ = 0\n\nfor A_ in A:\n a_ = a_ + A_\n a_li.append(a_)\n\nfor B_ in B:\n b_ = b_ + B_\n b_li.append(b_)\n\nbook_max = 0\nbook_cnt_a = 0\nbook_cnt_ab = 0\n\nfor a_ in a_li:\n book_cnt_ab = M\n for b_ in b_li.reverse():\n if (a_ + b_) < K:\n if (book_max <= book_cnt_ab + book_cnt_a):\n book_max = book_cnt_ab + book_cnt_a\n break\n book_cnt_ab = book_cnt_ab - 1\n book_cnt_a = book_cnt_a + 1\n\nprint(book_max)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nb_li = [0]\nb_ = 0\n\nfor B_ in B:\n b_ = b_ + B_\n b_li.append(b_)\n\nbook_max = 0\nbook_cnt_a = 0\nbook_cnt_ab = 0\na_ = 0\nbook_cnt_ab = M\n\nfor i in range(N+1):\n while (b_li[book_cnt_ab-1] + a_) > K:\n book_cnt_ab = book_cnt_ab - 1\n if book_cnt_ab < 0: break\n if book_cnt_ab < 0: break\n if (book_max <= book_cnt_ab + book_cnt_a):\n book_max = book_cnt_ab + book_cnt_a\n book_cnt_a = book_cnt_a + 1\n if i >= N: break\n a_ = a_ + A[i]\n\nprint(book_max)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nbook_max = 0\nbook_cnt = 0\n\nAsum = 0\nfor ia in range(N+1):\n Bsum = 0\n for ib in range(M+1):\n if K < (Asum + Bsum): break\n if ib == M: break\n Bsum = Bsum + B[ib]\n book_cnt = book_cnt + 1\n if book_max < (book_cnt - 0):\n book_max = book_cnt\n if ia == N: break\n Asum = Asum + A[ia]\n book_cnt = ia + 1\n if book_max < (book_cnt - 0):\n book_max = book_cnt\n\nprint(book_max)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nb_li = [0]\nb_ = 0\n\nfor B_ in B:\n b_ = b_ + B_\n b_li.append(b_)\n\nbook_max = 0\nbook_cnt_a = 0\nbook_cnt_ab = 0\na_ = 0\nbook_cnt_ab = M\n\nfor i in range(N+1):\n while (b_li[book_cnt_ab-1] + a_) > K:\n book_cnt_ab = book_cnt_ab - 1\n if (book_max <= book_cnt_ab + book_cnt_a):\n book_max = book_cnt_ab + book_cnt_a\n book_cnt_a = book_cnt_a + 1\n if i >= N: break\n a_ = a_ + A[i]\n\nprint(book_max)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nAsum_li = [0]\nAsum = 0\nBsum_li = [0]\nBsum = 0\n\nfor A_ in A:\n Asum = Asum + A_\n Asum_li.append(Asum)\n\nfor B_ in B:\n Bsum = Bsum + B_\n Bsum_li.append(Bsum)\n\ncnt_max = 0\ncnt_b = M\n\nfor cnt_a in range(N+1):\n\n if Asum_li[cnt_a] > K : break\n\n while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:\n cnt_b = cnt_b - 1\n if cnt_b < 0: break\n\n if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b\n\n\nprint(cnt_max)\n\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s116358310', 's619615928', 's689691097', 's751574820', 's755116056', 's993683603', 's878693041']
[40556.0, 40632.0, 47372.0, 40552.0, 40724.0, 40312.0, 47660.0]
[272.0, 2206.0, 172.0, 245.0, 2206.0, 269.0, 248.0]
[568, 545, 597, 596, 544, 532, 540]
p02623
u608007704
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\n\n\nAsum=[0]\nfor i in A:\n Asum.append(Asum[-1]+i)\n if(Asum[-1]>K):break\n \nBsum=[0]\nfor i in B:\n Bsum.append(Bsum[-1]+i)\n if(Bsum[-1]>K):break\nprint(Asum,Bsum)\n\nmaxval=len(Asum)-1\n\nfor i in range(len(Asum)):\n for j in range(len(Bsum)):\n if Asum[-i-1]+Bsum[j]>K:\n maxval=max(maxval,len(Asum)-1-i+j-1)\n print(i,j)\n break\n elif j==len(Bsum)-1:\n print(i,j)\n maxval=max(maxval,len(Asum)-1-i+j)\n \nprint(maxval)', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nAsum=[0]\nfor i in A:\n if Asum[-1]+i>K:break\n Asum.append(Asum[-1]+i)\nimport numpy as np\nAsum=np.array(Asum)\nBsum=[0]\nfor i in B:\n if Bsum[-1]+i>K:break\n Bsum.append(Bsum[-1]+i)\nBsum=np.array(Bsum)\n\nmaxval=len(Asum)-1\n\ntmp=0\nlenB=len(Bsum)\nlenA=len(Asum)\nfor i in range(lenA):\n if lenA-1-i+lenB<maxval:break\n for j in range(lenB):\n j=tmp+j\n if Asum[-i-1]+Bsum[j]>K:\n maxval=max(maxval,len(Asum)-1-i+j-1)\n tmp=j\n break\n elif j==lenB-1:\n maxval=max(maxval,lenA-1-i+j)\n break\nprint(maxval)\n']
['Wrong Answer', 'Accepted']
['s987035790', 's889910899']
[46892.0, 53716.0]
[2213.0, 745.0]
[543, 624]
p02623
u609561564
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nmax_num = 0\nj = 0\nj_max = M + 1\nA_sums=[sum(A[:i]) for i in range(N+1)]\nB_sums=[sum(B[:i]) for i in range(M+1)]\n\nfor i in range(N + 1):\n j = 0\n while j < j_max:\n print(i, j)\n if A_sums[i] + B_sums[j] > K:\n j_max = j\n break\n\n max_num = max(max_num, i + j)\n j += 1\nprint(max_num)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nmax_num = 0\nj = 0\nj_max = M + 1\nA_sums=[sum(A[:i]) for i in range(N+1)]\nB_sums=[sum(B[:i]) for i in range(M+1)]\n\nfor i in range(N + 1):\n j = 0\n while j < j_max:\n print(i, j)\n if A_sums[i] + B_sums[j] > K:\n j_max = j\n break\n\n max_num = max(max_num, i + j)\n j += 1\nprint(max_num)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nmax_num = 0\nj = 0\nj_max = M\nA_sums=[0]\nB_sums=[0]\nfor i in range(N):\n A_sums.append(A_sums[i]+A[i])\nfor i in range(M):\n B_sums.append(B_sums[i]+B[i])\n\n\nfor i in range(N + 1):\n j = 0\n if A_sums[i]>K:\n break\n while A_sums[i]+B_sums[j_max] > K:\n j_max -=1\n\n max_num = max(max_num, i + j_max)\nprint(max_num)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s052283711', 's485681618', 's267039856']
[42164.0, 42204.0, 47376.0]
[2206.0, 2207.0, 323.0]
[443, 443, 445]
p02623
u614875193
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nA=[0]+A\nB=[0]+B\n\nfrom itertools import accumulate\n\nAA=list(accumulate(A))\nBB=list(accumulate(B))\n\n\n\nprint(AA)\nprint(BB)\n\ntimer=0\ncount=0\na,b=0,0\n\nimport bisect\nfor i in range(N+1):\n a=i\n b=bisect.bisect_right(BB,K-AA[i])-1\n if b==-1:\n continue\n count=max(count,a+b)\n #print(a,b,count,AA[a]+BB[b])\nprint(count)\n\n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nA=[0]+A\nB=[0]+B\n\nfrom itertools import accumulate\n\nAA=list(accumulate(A))\nBB=list(accumulate(B))\na,b=0,0\n\nimport bisect\nfor i in range(N+1):\n a=i\n b=bisect.bisect_right(BB,K-AA[i])-1\n if b==-1:\n continue\n count=max(count,a+b)\nprint(count)\n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nA=[0]+A\nB=[0]+B\n\nfrom itertools import accumulate\n\nAA=list(accumulate(A))\nBB=list(accumulate(B))\ncount=0\na,b=0,0\n\nimport bisect\nfor i in range(N+1):\n a=i\n b=bisect.bisect_right(BB,K-AA[i])-1\n if b==-1:\n continue\n count=max(count,a+b)\nprint(count)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s212310759', 's299329107', 's661010106']
[54824.0, 47360.0, 47348.0]
[347.0, 135.0, 279.0]
[430, 355, 362]
p02623
u616382321
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\n\nfor i in range(M):\n b.append(B[i] + B[i])\n\nans, j = 0, M\n\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\n\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\n\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s595173943', 's894411258']
[44356.0, 47508.0]
[287.0, 358.0]
[362, 362]
p02623
u616542081
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\na = list(map(int,input().split()))\nb = list(map(int, input().split()))\n \nans_list = []\nans_list.append(0)\n\nsum_a = 0\nfor i in range(len(a)):\n sum_a += a[i]\n sum_b = 0\n if sum_a > k:\n break\n if sum_a == k:\n temp = i+1\n ans_list.append(temp)\n break\n for j in range(len(b)):\n if max(ans_list) < i+1+j:\n pass\n else:\n sum_b += b[j]\n if (sum_a + sum_b) > k:\n temp = i+1+j\n ans_list.append(temp)\n break\n if (sum_a + sum_b) == k:\n temp = i+1+j+1\n ans_list.append(temp)\n break\n \nsum_b = 0\nfor i in range(len(b)):\n sum_b += b[i]\n sum_a = 0\n if sum_b > k:\n break\n if sum_b == k:\n temp = i+1\n ans_list.append(temp)\n break\n for j in range(len(a)):\n if max(ans_list) < i+1+j:\n pass\n else:\n sum_a += a[j]\n if (sum_b + sum_a) > k:\n temp = i+1+j\n ans_list.append(temp)\n break\n if (sum_b + sum_a) == k:\n temp = i+1+j+1\n ans_list.append(temp)\n break\n \nprint(max(ans_list))', 'n, m, k = map(int, input().split())\na = list(map(int,input().split()))\nb = list(map(int, input().split()))\n\n\nans = 0\nsum_a = 0\nfor i in range(len(a)):\n sum_a += a[i]\n sum_b = 0\n if sum_a > k:\n break\n if sum_a == k:\n temp = i+1\n if temp > ans:\n ans = temp\n break\n for j in range(len(b)):\n sum_b += b[j]\n if (sum_a + sum_b) > k:\n temp = i+1+j\n ans_list.append(temp)\n if temp > ans:\n ans = temp\n break\n if (sum_a + sum_b) == k:\n temp = i+1+j+1\n if temp > ans:\n ans = temp\n break\n \nsum_b = 0\nfor i in range(len(b)):\n sum_b += b[i]\n sum_a = 0\n if sum_b > k:\n break\n if sum_b == k:\n temp = i+1\n if temp > ans:\n ans = temp\n break\n for j in range(len(a)):\n sum_a += a[j]\n if (sum_b + sum_a) > k:\n temp = i+1+j\n if temp > ans:\n ans = temp\n break\n if (sum_b + sum_a) == k:\n temp = i+1+j+1\n if temp > ans:\n ans = temp\n break\n \nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int,input().split()))\nb = list(map(int, input().split()))\n \nans_list = []\nans_list.append(0)\n\nsum_a = 0\nfor i in range(len(a)):\n sum_a += a[i]\n sum_b = 0\n if sum_a > k:\n break\n if sum_a == k:\n temp = i+1\n ans_list.append(temp)\n break\n for j in range(len(b)):\n sum_b += b[j]\n if max(ans_list) < i+1+j:\n pass\n else:\n if (sum_a + sum_b) > k:\n temp = i+1+j\n ans_list.append(temp)\n break\n if (sum_a + sum_b) == k:\n temp = i+1+j+1\n ans_list.append(temp)\n break\n \nsum_b = 0\nfor i in range(len(b)):\n sum_b += b[i]\n sum_a = 0\n if sum_b > k:\n break\n if sum_b == k:\n temp = i+1\n ans_list.append(temp)\n break\n for j in range(len(a)):\n sum_a += a[j] \n if max(ans_list) < i+1+j:\n pass\n else:\n if (sum_b + sum_a) > k:\n temp = i+1+j\n ans_list.append(temp)\n break\n if (sum_b + sum_a) == k:\n temp = i+1+j+1\n ans_list.append(temp)\n break\n \nprint(max(ans_list))', 'n, m, k = map(int, input().split())\na = list(map(int,input().split()))\nb = list(map(int, input().split()))\n \nans_list = []\nans_list.append(0)\n\nsum_a = 0\nfor i in range(len(a)):\n sum_a += a[i]\n if sum_a > k:\n break\n if sum_a == k:\n ans_list.append(i+1)\n break\n start = max(ans_list)-i\n sum_b = sum(b[0:start])\n for j in range(start,len(b)):\n sum_b += b[j]\n if (sum_a + sum_b) < k:\n ans_list.append(i+1+j)\n if (sum_a + sum_b) > k:\n ans_list.append(i+1+j-1)\n break\n if (sum_a + sum_b) == k:\n ans_list.append(i+1+j+1)\n break\n \nsum_b = 0\nfor i in range(len(b)):\n sum_b += b[i]\n sum_a = 0\n if sum_b > k:\n break\n if sum_b == k:\n ans_list.append(i+1)\n break\n start = max(ans_list)-i\n sum_a = sum(a[0:start])\n for j in range(start,len(a)):\n sum_a += a[j] \n if (sum_a + sum_b) < k:\n ans_list.append(i+1+j)\n if (sum_a + sum_b) > k:\n ans_list.append(i+1+j-1)\n break\n if (sum_a + sum_b) == k:\n ans_list.append(i+1+j+1)\n break\n \nprint(max(ans_list))', 'N, M, K = map(int, input().split())\nA = list(map(int,input().split()))\nB = list(map(int, input().split()))\na = [0]\nb = [0]\n\nans = 0\nj = M\n\nfor i in range(N):\n a.append(a[i] + A[i])\n\nfor i in range(M):\n b.append(b[i] + B[i])\n\nfor i in range(N+1):\n if a[i] > K:\n break\n while a[i] + b[j] > K:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s260386404', 's490662950', 's559983431', 's725811977', 's297763460']
[41744.0, 40112.0, 41796.0, 39868.0, 47376.0]
[2206.0, 2206.0, 2206.0, 2206.0, 304.0]
[1069, 991, 1069, 1052, 342]
p02623
u617037231
2,000
1,048,576
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.
['import math\nimport sys\nimport itertools\nfrom math import gcd\nfrom math import sqrt\nfrom sys import stdin\ndef input() : return stdin.readline().rstrip()\ndef mips():\n return map(int,input().split())\ndef ii():\n return int(input())\nsys.setrecursionlimit(10**9)\n\nN,M,K = mips()\nA = [i for i in mips()]\nB = [i for i in mips()]\n# N,M <= 200000\nans = 0\nclock = K\nA2 = [0]\nB2 = [0]\nfor i in range(1,N+1):\n ai = A2[i-1] + A[i-1]\n A2.append(ai)\nfor i in range(1,M+1):\n bi = B2[i-1] + B[i-1]\n B2.append(bi)\nfor i in range(N+1):\n j = M\n if A[i] > K:\n break\n while (j >= 0):\n if A2[i] + B2[j] <= K:\n ans = max(ans,i+j)\n j -= 1\nprint(ans)', 'import math\nimport sys\nimport itertools\nfrom math import gcd\nfrom math import sqrt\nfrom sys import stdin\ndef input() : return stdin.readline().rstrip()\ndef mips():\n return map(int,input().split())\ndef ii():\n return int(input())\nsys.setrecursionlimit(10**9)\n\nN,M,K = mips()\nA = [i for i in mips()]\nB = [i for i in mips()]\n# N,M <= 200000\nans = 0\nclock = K\nA2 = [0]\nB2 = [0]\nfor i in range(1,N+1):\n ai = A2[i-1] + A[i-1]\n A2.append(ai)\nfor i in range(1,M+1):\n bi = B2[i-1] + B[i-1]\n B2.append(bi)\nj = M\nfor i in range(N+1):\n if A2[i] > K:\n break\n while (B2[j] + A2[i] > K):\n j -= 1\n ans = max(ans,i+j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s365324724', 's427692375']
[47824.0, 47588.0]
[2207.0, 340.0]
[682, 651]
p02623
u623659526
2,000
1,048,576
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.
['import logging\n\nlogging.basicConfig(level=logging.INFO)\nlogging.info(\'info\')\n\n\ndef main():\n N, M, K = map(int, input().split())\n A_list = list(map(int, input().split()))\n B_list = list(map(int, input().split()))\n logging.info("hello")\n\n a = [0]\n b = [0]\n\n for i in range(N):\n a.append(a[i] + A_list[i])\n\n for i in range(M):\n b.append(b[i] + B_list[i])\n\n ans = 0\n j = M\n for i in range(N + 1):\n if a[i] > K:\n break\n for j in range(M):\n if b[j] > K - a[i]:\n else:\n ans = max(ans, i + j)\n break\n print(ans)\n\nif __name__ == "__main__":\n main()', 'import logging\n\nlogging.basicConfig(level=logging.INFO)\nlogging.info(\'info\')\n\n\ndef main():\n N, M, K = map(int, input().split())\n A_list = list(map(int, input().split()))\n B_list = list(map(int, input().split()))\n logging.info("hello")\n\n a = [0]\n b = [0]\n\n for i in range(N):\n a.append(a[i] + A_list[i])\n\n for i in range(M):\n b.append(b[i] + B_list[i])\n\n ans = 0\n #j = M\n for i in range(N + 1):\n if a[i] > K:\n break\n for j in range(M):\n if b[M - j] > K - a[i]:\n continue\n else:\n break\n\n ans = max(ans, i + M - j + 1)\n\n print(ans)\n\nif __name__ == "__main__":\n main()', 'import logging\n\nlogging.basicConfig(level=logging.INFO)\nlogging.info(\'info\')\n\n\ndef main():\n N, M, K = map(int, input().split())\n A_list = list(map(int, input().split()))\n B_list = list(map(int, input().split()))\n logging.info("hello")\n\n a = [0]\n b = [0]\n\n for i in range(N):\n a.append(a[i] + A_list[i])\n\n for i in range(M):\n b.append(b[i] + B_list[i])\n\n ans = 0\n j = M\n for i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\n print(ans)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s262404096', 's517679246', 's707484919']
[8948.0, 49036.0, 49164.0]
[24.0, 2207.0, 233.0]
[669, 701, 613]
p02623
u626891113
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = input().split()\nB = input().split()\nfor i in range(len(A)):\n A[i] = int(A[i])\nfor i in range(len(B)):\n B[i] = int(B[i])\nA.reverse()\nB.reverse()\nKK = 0\nc= 0\nwhile KK <= K:\n if len(A) == 0:\n KK += B[0]\n if KK <= K:\n c += 0\n if len(B) == 0:\n KK += A[0]\n if KK <= K:\n c += 0\n if len(A) == 0 and len(B) == 0:\n KK += K + 1\n if len(A) != 0 and len(B) != 0:\n if A[0] < B[0]:\n KK += A[0]\n if KK <= K:\n c += 0\n del A[0]\n else:\n KK += B[0]\n if KK <= K:\n c += 0\n del B[0]\n \nprint(c)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nsum_A = [0]\nfor i in range(N):\n sum_A.append(sum_A[i] + A[i])\n\nsum_B = [0]\nfor i in range(M):\n sum_B.append(sum_B[i] + B[i])\n\nans = 0\nj = M\n\nfor i in range (N+1):\n if sum_A[i] > K:\n break\n while sum_B[j] > K - sum_A[i]:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s463993580', 's047348278']
[40192.0, 47548.0]
[2206.0, 282.0]
[700, 401]
p02623
u627600101
2,000
1,048,576
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.
['N ,M ,K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = 0\nb = 0\nans = 0\nfor k in range(len(A)):\n a += A[k]\n A[k] = a\nfor k in range(len(B)):\n b += B[k]\n B[k] = b\n\nAA = [0] + A\n\nBB = [0] + B\n\nfor k in range(N+1):\n if AA[k] <= K:\n for j in range(M, -1, -1):\n if AA[k] + BB[j+1]> K >= AA[k] + BB[j]:\n ans = max(k+j, ans)\n break\n else:\n continue\n if K >= AA[k] + BB[M]:\n ans = max(k+M, ans)\n else:\n break\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s467211867', 's300849338']
[40564.0, 47324.0]
[197.0, 304.0]
[586, 342]
p02623
u628285938
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\n"""\nCreated on Mon Sep 7 11:05:00 2020\n\n@author: liang\n"""\n\n\nN, M, K = map(int, input().split())\n\nA = [0] + [int(x) for x in input().split()]\nB = [0] + [int(x) for x in input().split()]\n\ns_b = 0\nfor i in range(M+1):\n s_b += B[i]\n if s_b > K:\n s_b -= B[i]\n best = i - 1\n break\nres = best\n#print(res)\ns_a = 0\nfor i in range(N+1):\n # print("i", i)\n s_a += A[i]\n if s_a > K:\n break\n for j in reversed(range(best+1)):\n #print("j",j)\n if s_b <= K - s_a:\n if i + j > res:\n res = i + j\n best = j\n #print(i, j, s_a, s_b)\n break\n else:\n s_b -= B[j]', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0]*(N+1), [0]*(M+1)\nfor i in range(N):\n\ta[i+1] = a[i] + A[i] \nfor i in range(M):\n\tb[i+1] = b[i] + B[i]\n \nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s210786715', 's227694669']
[39968.0, 46888.0]
[310.0, 290.0]
[954, 346]
p02623
u630467326
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\n print(a)\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n', 'import sys\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nAB_list = []\ntime_sum = 0\nans = 0\n\nif A[0] > K or B[0] > K:\n print(0)\n sys.exit()\n\nfor _ in range(len(A) + len(B)):\n if len(A) == 0:\n AB_list.append(B[0])\n B.pop(0)\n elif len(B) == 0:\n AB_list.append(A[0])\n A.pop(0)\n elif A[0] <= B[0]:\n AB_list.append(A[0])\n A.pop(0)\n else:\n AB_list.append(B[0])\n B.pop(0)\n \nfor i in range(len(AB_list)):\n time_sum += AB_list[0]\n if time_sum > K:\n break\n ans += 1\n \nprint(ans)\n ', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s101193034', 's876110004', 's985287343']
[157200.0, 39764.0, 47496.0]
[1359.0, 2206.0, 285.0]
[359, 573, 344]
p02623
u633355062
2,000
1,048,576
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.
['import sys\n\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nns = lambda: readline().rstrip() # input string\nni = lambda: int(readline().rstrip()) # input int\nnm = lambda: map(int, readline().split()) # input multiple int \nnl = lambda: list(map(int, readline().split())) # input multiple int to list\n\nn, m, k = nm()\na = nl()\nb = nl()\nans = 0\nsum_a = [0]*(n+1)\nsum_b = [0]*(m+1)\nfor i in range(1, n+1):\n sum_a[i] = sum_a[i-1] + a[i-1]\nfor i in range(1, m+1):\n sum_b[i] = sum_b[i-1] + b[i-1]\nans = 0\nbef_j = m\nprint(sum_a, sum_b)\nfor i in range(n+1):\n if sum_a[i] >= k:\n break\n for j in range(bef_j, -1, -1):\n if sum_a[i] + sum_b[j] <= k:\n ans = max(ans, i+j)\n bef_j = j\n break\nprint(ans)\n\n\n\n"""i_n = 0\ni_m = 0\nwhile True:\n if i_n >= n and i_m >= m:\n break\n elif i_n >= n:\n tmp = b[i_m]\n i_m += 1\n elif i_m >= m:\n tmp = a[i_n]\n i_n += 1\n else:\n if a[i_n] < b[i_m]:\n tmp = a[i_n]\n i_n += 1\n else:\n tmp = b[i_m]\n i_m += 1\n\n if tmp + time <= k:\n cnt += 1\n time += tmp\n else:\n break\nprint(cnt)"""', 'import sys\n\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nns = lambda: readline().rstrip() # input string\nni = lambda: int(readline().rstrip()) # input int\nnm = lambda: map(int, readline().split()) # input multiple int \nnl = lambda: list(map(int, readline().split())) # input multiple int to list\n\nn, m, k = nm()\na = nl()\nb = nl()\nans = 0\nsum_a = [0]*(n+1)\nsum_b = [0]*(m+1)\nfor i in range(1, n+1):\n sum_a[i] = sum_a[i-1] + a[i-1]\nfor i in range(1, m+1):\n sum_b[i] = sum_b[i-1] + b[i-1]\nans = 0\nbef_j = m\nfor i in range(n+1):\n if sum_a[i] >= k:\n break\n for j in range(m+1, -1, -1):\n if sum_a[i] + sum_b[j] <= k:\n ans = max(ans, i+j)\n bef_j = j\n break\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ncs_A = [0] \nfor i in A:\n cs_A.append(cs_A[-1] + i)\ncs_B = [0] \nfor i in B:\n cs_B.append(cs_B[-1] + i)\n\ndef is_ok(mid, v):\n if v + cs_B[mid] <= K:\n return True\n else:\n return False\n\ndef meguru_bisect(v, ng, ok):\n \n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid, v):\n ok = mid\n else:\n ng = mid\n return ok\nans = 0\nfor i in range(0, N+1):\n v = cs_A[i]\n idx = meguru_bisect(v, M+1, -1)\n if 0 <= idx <= M:\n if v + cs_B[idx] <= K:\n ans = max(ans, i + idx) \nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s161661906', 's364158465', 's065743473']
[54860.0, 47868.0, 47548.0]
[427.0, 228.0, 1074.0]
[1194, 737, 1022]
p02623
u636290142
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(n):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(n):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if a[i] > k:\n break\n while [b] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s878599868', 's956588467', 's639270217']
[47628.0, 47476.0, 47552.0]
[295.0, 180.0, 288.0]
[359, 358, 359]
p02623
u638970023
2,000
1,048,576
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.
['n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nasum = [0]*(n+1)\nbsum = [0]*(m+1)\nfor i in range(n):\n\tasum[i+1] = a[i] + asum[i]\nfor j in range(m): \n\tbsum[i+1] = b[j] + bsum[j]\nj = m\nres = 0\nfor i in range(n+1):\n\tif asum[i] > k:\n\t\tbreak\n\twhile asum[i] + bsum[j] > k:\n\t\tj-=1\n\tres = max(res,i+j)\nprint(res) \n\n', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nasum = [0]*(n+1)\nbsum = [0]*(m+1)\nfor i in range(n):\n\tasum[i+1] = a[i] + asum[i]\nfor j in range(m): \n\tbsum[j+1] = b[j] + bsum[j]\nj = m\nres = 0\nfor i in range(n+1):\n\tif asum[i] > k:\n\t\tbreak\n\twhile asum[i] + bsum[j] > k:\n\t\tj-=1\n\tres = max(res,i+j)\nprint(res) \n\n']
['Runtime Error', 'Accepted']
['s504029594', 's990786808']
[40492.0, 47492.0]
[251.0, 290.0]
[362, 362]
p02623
u640161402
2,000
1,048,576
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.
['import sys\nn,m,k = map(int,input().split())\na = list(map(int, input().strip().split()))\nb = list(map(int, input().strip().split()))\nsum = 0\n\nfor i in range(n):\n sum += a[i]\nfor i in range(m):\n sum += b[i]\n\nif sum<=k:\n print(n+m)\n sys.exit()\n\n\nsum = 0\ncnt =0\nwhile sum < k and (len(a) != 0 or len(b) != 0 ):\n if len(a) != 0 and len(b) != 0:\n if a[0]<b[0]:\n sum += a[0]\n del a[0]\n else:\n sum += b[0]\n del b[0]\n elif len(a) == 0:\n sum += b[0]\n del b[0]\n else :\n sum += a[0]\n del a[0]\n if sum<=k :\n cnt+=1\n break\n\nprint(cnt)', 'from itertools import chain\n\n\ndef solve():\n N, M, K = map(int, input().split())\n\n A = map(int, input().split())\n B = list(map(int, input().split()))\n\n answer = 0\n\n sum_b = sum(B)\n idx_b = M\n remain = K\n\n for i, a in enumerate(chain([0], A)):\n remain -= a\n if remain < 0:\n break\n\n while sum_b > remain and idx_b >= 0:\n idx_b -= 1\n b = B[idx_b]\n sum_b -= b\n \n i += idx_b\n answer = i if answer < i else answer\n\n return answer\n\n\ndef main():\n print(solve())\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s694059343', 's354038006']
[40628.0, 48456.0]
[162.0, 151.0]
[645, 609]
p02623
u642528832
2,000
1,048,576
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.
['from bisect import bisect_right\n\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na_sum = [0]\nb_sum = [0]\nfor i in range(N):\n a_sum.append(a_sum[i]+a[i])\nfor i in range(M):\n b_sum.append(b_sum[i]+b[i])\n\nans = 0\n\nfor i in range(N+1):\n cntA = i \n rest = K - a_sum[i]\n if rest < 0:\n break\n cntB = bisect_right(b_sum,rest)-1 \n ans = max(ans,cntA + cntB)\n print(ans)\nprint(ans)', 'from bisect import bisect_right\n\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nA_sum = [0]\nB_sum = [0]\nfor i in range(N):\n A_sum.append(A_sum[i]+A[i])\nfor i in range(M):\n B_sum.append(B_sum[i]+B[i])\n\nans = 0\n\nfor i in range(N+1):\n cntA = i \n rest = K - A_sum[i] \n if rest < 0:\n break\n cntB = bisect_right(B_sum,rest)-1 \n ans = max(ans,cntA + cntB)\nprint(ans)']
['Runtime Error', 'Accepted']
['s250691947', 's942005296']
[40588.0, 47624.0]
[109.0, 321.0]
[615, 601]
p02623
u643679148
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\naa = list(map(int, input().split()))\nbb = list(map(int, input().split()))\nans = [0]\ntime_sum = 0\ni, j = 0, 0\n\nflag_a = True\nflag_b = True\nflag = False\nfor i in range(0, len(aa)+1):\n for j in range(0, len(bb)+1):\n asum, bsum = sum(aa[:i]), sum(bb[:j])\n if k < asum or k < bsum:\n flag = True\n break\n else:\n time_total = asum + bsum\n if time_total > k:\n break\n else:\n ans.append(i+j)\n if flag:\n break\n\nprint(max(ans))\n', "\n\ndef main3():\n n, m, k = map(int, input().split())\n aa = list(map(int, input().split()))\n bb = list(map(int, input().split()))\n time_sum = 0\n counter = 0\n ans = []\n\n if bb[0] >= aa[0]:\n if k < aa[0]:\n return counter\n if bb[0] <= aa[0]:\n if k < bb[0]:\n return counter\n\n if (sum(aa)+sum(bb)) <= k:\n return n+m\n\n for i in range(n+1):\n counter = i\n time_sum = sum(aa[:i])\n if time_sum > k:\n break\n elif time_sum == k:\n ans.append(counter)\n else:\n for j in range(1, m):\n time_sum += bb[j]\n if time_sum < k:\n counter += 1\n elif time_sum == k:\n counter += 1\n ans.append(counter)\n else:\n ans.append(counter)\n break\n\n if len(ans) == 1:\n return ans[0]\n else:\n return max(ans)\n\n\nif __name__ == '__main__':\n ans = main3()\n print(ans)\n", "\n\ndef main():\n n, m, k = map(int, input().split())\n aa = list(map(int, input().split()))\n bb = list(map(int, input().split()))\n time_sum = 0\n for i in range(n):\n for j in range(1, m):\n time_sum = aa[:i] + bb[:j]\n if time_sum <= k:\n ans.append(i+j)\n\n if(len(ans) == 1):\n return ans[0]\n else:\n return max(ans)\n\n\nif __name__ == '__main__':\n ans = main()\n print(ans)\n", 'n, m, k = map(int, input().split())\naa = list(map(int, input().split()))\nbb = list(map(int, input().split()))\nasum = [0]\nbsum = [0]\n\nfor i in range(len(aa)):\n asum.append(asum[i]+aa[i])\nfor i in range(len(bb)):\n bsum.append(bsum[i]+bb[i])\n\nj = len(bsum)-1\nans = 0\nfor i in range(len(asum)):\n while j >= 0:\n if k >= asum[i] + bsum[j]:\n ans = max(ans, i+j)\n break\n else:\n j -= 1\n\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s140775185', 's735030180', 's915260137', 's056112770']
[40440.0, 39852.0, 40432.0, 47368.0]
[2206.0, 2206.0, 118.0, 305.0]
[570, 1045, 448, 446]
p02623
u648315264
2,000
1,048,576
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.
['A,B,time = map(int,input().split())\nlist_A = list(map(int,input().split()))\nlist_B = list(map(int,input().split()))\n\n\n\nlist_A_num = -1\nlist_B_num = -1\n\ntotal_time = 0\ncount = 0\n\nwhile total_time < time:\n if len(list_A) > 0:\n if list_A[list_A_num] <= list_B[list_B_num]: \n total_time += list_A[list_A_num]\n list_A.pop()\n else:\n total_time += list_B[list_B_num]\n list_B.pop()\n else:\n total_time += list_B[list_B_num]\n list_B.pop()\n if total_time <= time:\n count += 1\n\nprint(count)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na,b = [0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s574945027', 's588353987']
[40580.0, 47548.0]
[233.0, 291.0]
[614, 348]
p02623
u655048024
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans = 0\nj = 0\nfor i in range(N + 1): \n if a[i]>K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nfor i in range(1,n):\n a[i] += a[i-1]\nfor i in range(1,m):\n b[i] += b[i-1]\nans = -100\nfor i in range(n):\n if(a[i]>k):\n break\n for j in range(1,m):\n if(a[i]+b[(-1)*j]>k):\n break\n ans = max(ans,i+j+1)\nprint(ans)\n', 'n,m,k = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\nans = -100\nfor i in range(n):\n if(a[i]>k):\n break\n for j in range(1,m):\n if(a[i]+b[(-1)*j]>k):\n break\n ans = max(ans,i+j)\nprint(ans)\n', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nfor i in range(1,n):\n a[i] += a[i-1]\nfor i in range(1,m):\n b[i] += b[i-1]\nans = -100\nfor i in range(n):\n if(a[i]>k):\n break\n for j in range(1,m):\n if(a[i]+b[(-1)*j]>k):\n break\n ans = max(ans,i+j+2)\nprint(ans)\n', 'n,m,k = map(int,input().split())\na = list(map(int.input().split()))\nb = list(map(int,input().split()))\nfor i in range(1,n):\n a[i] += a[i-1]\nfor i in range(1,m):\n b[i] += b[i-1]\nans = -100\nfor i in range(n):\n for j in range(m):\n if(a[i]+b[j]>=k):\n break\n ans = max(ans,a[i]+b[j])\nprint(ans)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nfor i in range(1,n):\n a[i] += a[i-1]\nfor i in range(1,m):\n b[i] += b[i-1]\nans = -100\nfor i in range(n):\n for j in range(m):\n if(a[i]+b[j]>=k):\n break\n ans = max(ans,a[i]+b[j])\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans = 0\nj = M\nfor i in range(N + 1): \n if a[i]>K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s171669580', 's845795697', 's859516159', 's878935262', 's882305007', 's938161270', 's522142995']
[47652.0, 40516.0, 47356.0, 40520.0, 9224.0, 40580.0, 47448.0]
[218.0, 2206.0, 2207.0, 2206.0, 26.0, 2206.0, 284.0]
[340, 331, 350, 331, 304, 305, 337]
p02623
u655663334
2,000
1,048,576
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.
['from collections import deque\nimport bisect\nN,M,K = list(map(int, input().split()))\nAs = list(map(int, input().split()))\nBs = list(map(int, input().split()))\n\n\n# print(N + M)\n# exit()\n\n\nAsruisekiwa = []\nBsruisekiwa = []\n\nAsruisekiwa.append(As[0])\nBsruisekiwa.append(Bs[0])\n\nfor i, j in enumerate(As[1:]):\n Asruisekiwa.append(Asruisekiwa[-1]+j)\n\nfor i, j in enumerate(Bs[1:]):\n Bsruisekiwa.append(Bsruisekiwa[-1] + j)\n\n#print(Asruisekiwa)\n#print(Bsruisekiwa)\n\nans = 0\n#print(Asruisekiwa)\n#print(Bsruisekiwa)\n\nif(Asruisekiwa[0] >= Bsruisekiwa[0]):\n tmp = Asruisekiwa\n Asruisekiwa = Bsruisekiwa\n Bsruisekiwa = tmp\n\nAsruisekiwa.insert(0,0)\nBsruisekiwa.insert(0,0)\n\n#print(Asruisekiwa)\n#print(Bsruisekiwa)\n\n\nfor index, i in enumerate(Asruisekiwa):\n\n if(i > K):\n break\n\n tmp = i\n maxcheck = K - i\n\n\n hoge = bisect.bisect_left(Bsruisekiwa, maxcheck)\n\n ans = max(ans, index + hoge)\n\n# print(ans, tmp, hoge, maxcheck)\n\nprint(ans)', 'from collections import deque\nimport bisect\nN,M,K = list(map(int, input().split()))\nAs = list(map(int, input().split()))\nBs = list(map(int, input().split()))\n\n\n# print(N + M)\n# exit()\n\n\nAsruisekiwa = []\nBsruisekiwa = []\n\nAsruisekiwa.append(As[0])\nBsruisekiwa.append(Bs[0])\n\nfor i, j in enumerate(As[1:]):\n Asruisekiwa.append(Asruisekiwa[-1]+j)\n\nfor i, j in enumerate(Bs[1:]):\n Bsruisekiwa.append(Bsruisekiwa[-1] + j)\n\n#print(Asruisekiwa)\n#print(Bsruisekiwa)\n\nans = 0\n#print(Asruisekiwa)\n#print(Bsruisekiwa)\n\nif(Asruisekiwa[0] >= Bsruisekiwa[0]):\n tmp = Asruisekiwa\n Asruisekiwa = Bsruisekiwa\n Bsruisekiwa = tmp\n\nAsruisekiwa.insert(0,0)\nBsruisekiwa.insert(0,0)\n\n#print(Asruisekiwa)\n#print(Bsruisekiwa)\n\n\nfor index, i in enumerate(Asruisekiwa):\n\n if(i > K):\n break\n\n tmp = i\n maxcheck = K - i\n\n\n hoge = bisect.bisect_right(Bsruisekiwa, maxcheck)\n\n ans = max(ans, index-1 + hoge)\n\n# print(ans, tmp, hoge, maxcheck)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s648066389', 's071508078']
[49260.0, 49492.0]
[355.0, 354.0]
[998, 997]
p02623
u660466744
2,000
1,048,576
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.
['N,M,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\ni_a = 0\ni_b = 0\n\ntotal_time = 0\n\nwhile True:\n if i_a == N and i_b == M:\n break\n else:\n if i_a == N:\n read_a = False:\n elif i_b ==M:\n read_a = True:\n elif A[i_a] <= B[i_b]:\n read_a = True\n \n if read_a:\n if A[i_a] <= K - total_time:\n total_time += A[i_a]\n i_a += 1\n else:\n break\n else:\n if B[i_b] <= K - total_time:\n total_time += B[i_b]\n i_b += 1\n else:\n break\n\nprint(int(i_a+i_b))', 'N,M,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na = [0]*(N+1)\nb = [0]*(M+1)\n\nfor i in range(N):\n a[i+1] = a[i] + A[i]\nfor j in range(M):\n b[j+1] = b[j] + B[j]\n\nn_b = M\nbest = 0\n\nfor n_a in range(N+1):\n if K < a[n_a]:\n break\n\n while K < a[n_a] + b[n_b]:\n n_b -= 1\n\n best = max(n_a + n_b,best)\n\nprint(int(best))\n\n']
['Runtime Error', 'Accepted']
['s725630256', 's440550505']
[8892.0, 47372.0]
[29.0, 317.0]
[660, 403]
p02623
u663796637
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nmax_count = 0\nfor i in range(n):\n\ta_sum = sum(a[:i + 1])\n\tfor j in range(m):\n\t\tb_sum = sum(b[:j + 1])\n\t\tif (a_sum + b_sum <= k) && (a_sum + b_sum > max_count):\n\t\t\tmax_count = i + j + 2\nprint(max_count)\n', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nmax_count = 0\na_sum = 0\nb_sum = 0\nfor i in range(n):\n\ta_sum += a[i]\n\tfor j in range(m):\n\t\tb_sum += b[j]\n\t\tif (a_sum + b_sum <= k) & (a_sum + b_sum > max_count):\n\t\t\tmax_count = i + j + 2\nprint(max_count)\n', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nacum1=[0]\nfor i in range(n):\n\tacum1.append(acum1[-1]+a[i])\nacum2=[0]\nfor i in range(m):\n\tacum2.append(acum2[-1]+b[i])\nans = 0\nj = m\nfor i in range(n + 1):\n\tif acum1[i] > k:\n\t\tbreak\n\twhile (j > 0) and (acum1[i] + acum2[j] > k):\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s308633608', 's424135173', 's855735180']
[9044.0, 40468.0, 47500.0]
[28.0, 2206.0, 286.0]
[311, 312, 379]
p02623
u665038048
2,000
1,048,576
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.
['from itertools import accumulate\nfrom bisect import bisect\n\nn, m, k = map(int, input().split())\na = [*accumulate(map(int, input().split()), initial=0)]\nb = [*accumulate(map(int, input().split()), initial=0)]\nans = 0\nfor i, x in enumerate(a):\n if x <= k:\n ans = max(i - 1 + bisect(b, k - x))\nprint(ans)\n', 'from itertools import accumulate\nfrom bisect import bisect\n\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na = [0] + list(accumulate(a))\nb = [0] + list(accumulate(b))\nans = 0\nj = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s760036159', 's019971866']
[45988.0, 41208.0]
[131.0, 233.0]
[312, 371]
p02623
u674343825
2,000
1,048,576
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.
['n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\na_sum = [0]\nb_sum = [0]\nfor i in range(n):\n a_sum.append(a[i]+a_sum[i])\n if a_sum[i]>1e+9:\n break\nfor i in range(m):\n b_sum.append(b[i]+b_sum[i])\n if b_sum[i]>1e+9:\n break\n \nans = 0\nfor i in range(len(b_sum)):\n if a_sum[i]>k:\n break\n time = k - a_sum[i]\n for j in range(len(b_sum)):\n if time<b_sum[j+1]:\n break\n if time>=b_sum[len(b_sum)]:\n j = len(b_sum)\n ans = max(ans,i+j)\n \nprint(ans)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\na_sum = [0]\nb_sum = [0]\nfor i in range(n):\n a_sum.append(a[i]+a_sum[i])\n if a_sum[i]>k:\n break\nfor i in range(m):\n b_sum.append(b[i]+b_sum[i])\n if b_sum[i]>k:\n break\n \nans = 0\ny = len(b_sum)-1\nfor i in range(len(a_sum)):\n if a_sum[i]>k:\n break\n time = k - a_sum[i]\n for j in range(y,-1,-1):\n if time>=b_sum[j]:\n y = j\n break\n if time>=b_sum[len(b_sum)-1]:\n j = len(b_sum)-1\n ans = max(ans,i+j)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s156408316', 's762442099']
[40780.0, 40444.0]
[249.0, 416.0]
[574, 603]
p02623
u674588203
2,000
1,048,576
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.
['import bisect\n\nN,M,K=map(int,inp().split())\nlist_a=list(map(int,inp().split()))\nlist_b=list(map(int,inp().split()))\n\n\ntotaltame_a=[0]\nfor a in list_a:\n temp_a=totaltame_a[-1]+a\n if temp_a>K:\n break\n else:\n totaltame_a.append(temp_a)\n\n\ntotaltime_b=[0]\nfor b in list_b:\n totaltime_b.append(totaltime_b[-1]+b)\n\nans=0\n\nfor i in range (len(totaltame_a)):\n Kb=K-totaltame_a[i]\n j=bisect.bisect_right(totaltime_b,Kb)-1\n if i+j>ans:\n ans=i+j\n else:\n pass\n\nprint(ans)', 'import bisect\n\nN,M,K=map(int,input().split())\nlist_a=list(map(int,input().split()))\nlist_b=list(map(int,input().split()))\n\n\ntotaltime_a=[0]\nfor a in list_a:\n temp_a=totaltime_a[-1]+a\n if temp_a>K:\n break\n else:\n totaltime_a.append(temp_a)\n\ntotaltime_b=[0]\nfor b in list_b:\n totaltime_b.append(totaltime_b[-1]+b)\n\nans=0\n\nfor i in range (len(totaltime_a)):\n Kb=K-totaltime_a[i]\n j=bisect.bisect_right(totaltime_b,Kb)-1\n if i+j>ans:\n ans=i+j\n else:\n pass\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s284574276', 's859651209']
[8968.0, 40764.0]
[22.0, 288.0]
[510, 566]
p02623
u685983477
2,000
1,048,576
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.
["import itertools\ndef main():\n n,m,k=map(int, input().split())\n a=[int(i) for i in input().split()]\n b=[int(i) for i in input().split()]\n\n ia = n-1\n res = n\n ib = 0\n time = sum(a)\n\n while(ia>=0 and ib<m):\n\n if(time > k):\n time -= (a[ia])\n res-=1\n ia-=1\n elif(time+b[ib]<=k):\n time += (b[ib])\n res+=1\n ib+=1\n else:\n break\n\n print(res)\n\nif __name__ == '__main__':\n main()\n", "import itertools\ndef main():\n n,m,k=map(int, input().split())\n a=[int(i) for i in input().split()]\n b=[int(i) for i in input().split()]\n a = [0]+list(itertools.accumulate(a))\n b = [0]+list(itertools.accumulate(b))\n res = 0\n j = m\n best=0\n i=0\n\n while(i<n+1):\n if(a[i]>k):\n break\n while(b[j]+a[i]>k):\n j-=1\n res = max(res,i+j)\n i+=1\n print(res)\n\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s282409780', 's092679286']
[9044.0, 41624.0]
[28.0, 201.0]
[495, 468]
p02623
u686036872
2,000
1,048,576
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.
['import bisect\n\nN, M, K = map(int, input().split())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0]\nb = [0]\nfor i in range(N):\n a += (a[i] + A[i])\nfor i in range(M):\n b += (b[i] + B[i])\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, i + bisect.bisect_right(b, K - a[i]))\n\nprint(ans)', 'import bisect\n\nN, M, K = map(int, input().split())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0]\nb = [0]\nfor i in range(N):\n a += [a[i] + A[i]]\nfor i in range(M):\n b += [b[i] + B[i]]\n\nans = 0\nfor i in range(N+1):\n if A[i] <= K:\n ans = max(ans, i + bisect.bisect_right(b, K - a[i])-1)\n\nprint(ans)', 'import bisect\n\nN, M, K = map(int, input().split())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0]\nb = [0]\nfor i in range(N):\n a += [a[i] + A[i]]\nfor i in range(M):\n b += [b[i] + B[i]]\n\nans = 0\nfor i in range(N+1):\n if a[i] <= K:\n ans = max(ans, i + bisect.bisect_right(b, K - a[i])-1)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s211875080', 's540683917', 's772742574']
[40484.0, 47416.0, 47548.0]
[112.0, 360.0, 327.0]
[323, 347, 347]
p02623
u687416863
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\n\nN,M,K = map(int, input().split())\nNnums = list(map(int, input().split()))\nMnums = list(map(int, input().split()))\n\nNmax=len(Nnums)\nMmax=len(Mnums)\nNsum=0\nNcnt=0\n\n\nfor Ni,Nl in enumerate(Nnums):\n Nsum += Nl\n Ncnt = Ni\n if Nsum > K:\n Nsum -= Nl\n Ncnt = Ni-1\n break\n \nchkSum = Nsum\nchkCnt = Ncnt + 1\nAnsCnt = Ncnt + 1\n\n\nfor Mi,Ml in enumerate(Mnums):\n chkSum += Ml\n chkCnt += 1\n if (chkSum > K):\n flg = 0\n while chkSum > K:\n if Ncnt >= 0:\n chkSum -= Nnums[Ncnt]\n chkCnt -= 1\n Ncnt -= 1\n flg = 1\n else:\n if flg == 0:\n \n chkCnt -= 1\n AnsCnt -= 1\n break\n \n if (AnsCnt < chkCnt):\n AnsCnt = chkCnt\n \n# if (Ncnt < 0):\n if (chkSum > K):\n break\n \nprint(AnsCnt)', '# -*- coding: utf-8 -*-\n\nN,M,K = map(int, input().split())\nNnums = list(map(int, input().split()))\nMnums = list(map(int, input().split()))\n\nNmax=len(Nnums)\nMmax=len(Mnums)\nNsum=0\nNcnt=0\n\n\nfor Ni,Nl in enumerate(Nnums):\n Nsum += Nl\n Ncnt = Ni\n if Nsum > K:\n Nsum -= Nl\n Ncnt = Ni-1\n break\n \nchkSum = Nsum\nchkCnt = Ncnt + 1\nAnsCnt = Ncnt + 1\n \n\nfor Mi,Ml in enumerate(Mnums):\n chkSum += Ml\n chkCnt += 1\n if (chkSum > K):\n if \n while chkSum > K:\n if not Ncnt < 0:\n chkSum -= Nnums[Ncnt]\n chkCnt -= 1\n Ncnt -= 1\n elif:\n break\n \n if (AnsCnt < chkCnt):\n AnsCnt = chkCnt\n \n if (Ncnt < 0):\n break\n\nprint(AnsCnt)\n', '# -*- coding: utf-8 -*-\n\nN,M,K = map(int, input().split())\nNnums = list(map(int, input().split()))\nMnums = list(map(int, input().split()))\n\nNmax=len(Nnums)\nMmax=len(Mnums)\nNsum=0\nNcnt=0\n\n\nfor Ni,Nl in enumerate(Nnums):\n Nsum += Nl\n Ncnt = Ni\n if Nsum > K:\n Nsum -= Nl\n Ncnt = Ni-1\n break\n \nchkSum = Nsum\nchkCnt = Ncnt + 1\nAnsCnt = Ncnt + 1\n\n\nfor Mi,Ml in enumerate(Mnums):\n chkSum += Ml\n chkCnt += 1\n if (chkSum > K):\n while chkSum > K:\n if Ncnt >= 0:\n chkSum -= Nnums[Ncnt]\n chkCnt -= 1\n Ncnt -= 1\n else:\n \n chkCnt -= 1\n AnsCnt -= 1\n break\n \n if (AnsCnt < chkCnt):\n AnsCnt = chkCnt\n \n# if (Ncnt < 0):\n if (chkSum > K):\n break\n \nprint(AnsCnt)', '# -*- coding: utf-8 -*-\n\nN,M,K = map(int, input().split())\nNnums = list(map(int, input().split()))\nMnums = list(map(int, input().split()))\n\nNmax=len(Nnums)\nMmax=len(Mnums)\nNsum=0\nNcnt=0\n\n\nfor Ni,Nl in enumerate(Nnums):\n Nsum += Nl\n Ncnt = Ni\n if Nsum > K:\n Nsum -= Nl\n Ncnt = Ni-1\n break\n \nchkSum = Nsum\nchkCnt = Ncnt + 1\nAnsCnt = Ncnt + 1\n\n\nfor Mi,Ml in enumerate(Mnums):\n chkSum += Ml\n chkCnt += 1\n if (chkSum > K):\n flg = 0\n while chkSum > K:\n if Ncnt >= 0:\n chkSum -= Nnums[Ncnt]\n chkCnt -= 1\n Ncnt -= 1\n flg = 1\n else:\n if flg == 0:\n \n chkCnt -= 1\n #AnsCnt -= 1\n break\n \n if (AnsCnt < chkCnt):\n AnsCnt = chkCnt\n \n\n \n# if (Ncnt < 0):\n if (chkSum > K):\n break\n \nprint(AnsCnt)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s114618383', 's652090037', 's716729467', 's866438429']
[41008.0, 9068.0, 40584.0, 41036.0]
[252.0, 24.0, 244.0, 245.0]
[921, 794, 866, 926]
p02623
u687574784
2,000
1,048,576
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.
['n,m,k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfrom itertools import accumulate\nimport bisect\ncumsum_a = list(accumulate(a))\ncumsum_b = list(accumulate(b))\n\nans = 0\nfor i in range(n+1):\n cnt_a = bisect.bisect(cumsum_a[:i], k)\n time = k - cumsum_a[cnt_a - 1]\n if time <= 0:\n break\n \n cnt_b = bisect.bisect(cumsum_b, time)\n \n ans = max(ans, cnt_a + cnt_b)\n\nfor i in range(m+1):\n cnt_b = bisect.bisect(cumsum_b[:i], k)\n time = k - cumsum_b[cnt_b - 1]\n if time <= 0:\n break\n\n cnt_a = bisect.bisect(cumsum_a, time)\n \n ans = max(ans, cnt_a + cnt_b)\n\nprint(ans)', 'n,m,k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfrom itertools import accumulate\nimport bisect\ncumsum_a = list(accumulate(a))\ncumsum_b = list(accumulate(b))\n\nans = 0\nfor i in range(1, n+1):\n if cumsum_a[i-1] > k:\n break\n \n cnt_b = bisect.bisect(cumsum_b, k - cumsum_a[i-1])\n ans = max(ans, i + cnt_b)\n\nfor i in range(1, m+1):\n if cumsum_b[i-1] > k:\n break\n \n cnt_a = bisect.bisect(cumsum_a, k - cumsum_b[i-1])\n ans = max(ans, i + cnt_a)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s958218122', 's437719442']
[47500.0, 48524.0]
[2207.0, 429.0]
[673, 551]
p02623
u688219499
2,000
1,048,576
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.
['import numpy as np\nn, m, k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ncum_a = np.r_[0,np.cumsum(a)]\n# cum_b = np.r_[0, np.cumsum(b)]\n# cum_a = np.cumsum(a)\ncum_b = np.cumsum(b)\n# high = m\n# low = 0\n\nans = 0\nfor i in range(n + 1):\n \n # while 1:\n # mid = (high + low) // 2\n \n # if cum_a[i] + cum_b[mid] >= k:\n # high = mid\n # else:\n # low = mid - 1\n # if low == high:\n # break\n if cum_a[i] > k:\n \n # print(s, i, ans)\n # break\n i = 0\n # else:\n s = np.searchsorted(cum_b, k - cum_a[i])#, side = "right")\n print(i, s)\n ans = max(ans, i + s)\nprint(ans)', 'import numpy as np\nn, m, k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ncum_a = np.r_[0,np.cumsum(a)]\ncum_b = np.r_[0, np.cumsum(b)]\nans = 0\nfor i in range(n + 1):\n if cum_a[i] > k:\n break\n else:\n s = np.searchsorted(cum_b, k - cum_a[i] - 1)\n ans = max(ans, i + s)\n\nprint(ans)', 'import numpy as np\nn, m, k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ncum_a = np.r_[0,np.cumsum(a)]\n# cum_b = np.r_[0, np.cumsum(b)]\n# cum_a = np.cumsum(a)\ncum_b = np.cumsum(b)\n# high = m\n# low = 0\n\nans = 0\nfor i in range(n + 1):\n \n # while 1:\n # mid = (high + low) // 2\n \n # if cum_a[i] + cum_b[mid] >= k:\n # high = mid\n # else:\n # low = mid - 1\n # if low == high:\n # break\n if cum_a[i] > k:\n \n # print(s, i, ans)\n # break\n i = 0\n # else:\n s = np.searchsorted(cum_b, k - cum_a[i], side = "right")\n\n ans = max(ans, i + s)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s620860771', 's879371368', 's642891800']
[58480.0, 58252.0, 58660.0]
[1073.0, 870.0, 824.0]
[805, 355, 788]
p02623
u692054751
2,000
1,048,576
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.
['#!/usr/bin/env python3\nN, M, K = [int(s) for s in input().split()]\nA = [int(s) for s in input().split()]\nB = [int(s) for s in input().split()]\ni = 0\nj = M-1\n\nB_SUM = [0] * M\nB_SUM[0] = B[0]\n\nmax_book = 0\n\nfor i in range(1, M):\n B_SUM[i] = B[i] + B_SUM[i - 1]\n if B_SUM[i] <= K:\n max_book = i + 1\n\nA_SUM = 0\n\nb_index = M - 1\n\nfor i in range(N):\n A_SUM += A[i]\n while (b_index >= 0):\n B_SUM[b_index]\n if A_SUM + B_SUM <= K:\n break\n b_index -= 1\n max_book = max(max_book, b_index + 1 + i + 1)\n\nprint(max_book)', '#!/usr/bin/env python3\nN, M, K = [int(s) for s in input().split()]\nA = [int(s) for s in input().split()]\nB = [int(s) for s in input().split()]\ni = 0\nj = M-1\n\nB_SUM = [0] * M\nA_SUM = [0] * N\nB_SUM[0] = B[0]\nA_SUM[0] = A[0]\nmax_book = 0\n\nif B_SUM[0] <= K:\n max_book = 1\n\nfor i in range(1, M):\n B_SUM[i] = B[i] + B_SUM[i - 1]\n if B_SUM[i] <= K:\n max_book = i + 1\n\nA_SUM = 0\nb_index = M - 1\n\nfor i in range(N):\n A_SUM += A[i]\n while (b_index >= 0):\n B_SUM[b_index]\n if A_SUM + B_SUM[b_index] <= K:\n max_book = max(max_book, b_index + 1 + i + 1)\n break\n b_index -= 1\n if (A_SUM <= K):\n max_book = max(max_book, i + 1)\nprint(max_book)']
['Runtime Error', 'Accepted']
['s745714192', 's585591385']
[40568.0, 41808.0]
[184.0, 366.0]
[560, 703]
p02623
u693007703
2,000
1,048,576
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.
['N, M, K = [int(i) for i in input().split()]\n\nAs = [int(i) for i in input().split()]\nBs = [int(i) for i in input().split()]\n\ncnt = 0\ntime = 0\nwhile time <= K:\n if As and Bs:\n if As[0] > Bs[0]:\n p = Bs.pop(0)\n elif Bs[0] >= As[0]:\n p = As.pop(0)\n else :\n else :\n if As:\n p = As.pop(0)\n elif Bs:\n p = Bs.pop(0)\n else :\n break\n time += p\n if time > K:\n break\n cnt += 1\n \nprint(cnt)', 'N, M, K = [int(i) for i in input().split()]\n\narray_A = [int(i) for i in input().split()]\narray_B = [int(i) for i in input().split()]\n\narray_A_2 = [0]\narray_B_2 = [0]\n\nfor a in array_A:array_A_2.append(array_A_2[- 1]+a)\nfor b in array_B:array_B_2.append(array_B_2[- 1]+b)\n\noutput, j = 0, M\n\nfor i in range(N + 1):\n if array_A_2[i] > K:\n break\n while array_B_2[j] > K - array_A_2[i]:\n j -= 1\n output = max(output, i + j)\n\nprint(output)']
['Runtime Error', 'Accepted']
['s036091233', 's340458697']
[8936.0, 47548.0]
[23.0, 300.0]
[499, 456]
p02623
u693025087
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\nsum_A = [0]\nsum_B = [0]\nfor n in range(N):\n sum_A.append(sum_A[n]+A[n])\nfor m in range(M):\n sum_B.append(sum_B[m]+B[m])\n\nmax_j = M\nmax_book = 0\nfor i in range(N+1):\n \n if sum_A > K:\n break\n for j in range(max_j,-1,-1):\n if sum_A[i]+sum_B[j] <= K:\n max_j = j\n break\n else:\n max_j = 0\n \n max_book = max(max_book, i+max_j)\n\nprint(max_book)\n', '# -*- coding: utf-8 -*-\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nif sum(A)+sum(B) <= K:\n print(N+M)\n exit(0)\n\nsum_A = [0]\nsum_B = [0]\nfor n in range(N):\n sum_A.append(sum_A[n]+A[n])\nfor m in range(M):\n sum_B.append(sum_B[m]+B[m])\n\nmax_j = M\nmax_book = 0\nfor i in range(N+1):\n \n for j in range(max_j,-1,-1):\n if sum_A[i]+sum_B[j] <= K:\n max_j = j\n break\n else:\n max_j = 0\n print(i, max_j)\n max_book = max(max_book, i+max_j)\n\nprint(max_book)', '# -*- coding: utf-8 -*-\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\nsum_A = [0]\nsum_B = [0]\nfor n in range(N):\n sum_A.append(sum_A[n]+A[n])\nfor m in range(M):\n sum_B.append(sum_B[m]+B[m])\n\nmax_j = M\nmax_book = 0\nfor i in range(N+1):\n \n if sum_A[i] > K:\n break\n for j in range(max_j,-1,-1):\n if sum_A[i]+sum_B[j] <= K:\n max_j = j\n break\n else:\n max_j = 0\n \n max_book = max(max_book, i+max_j)\n\nprint(max_book)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s079049526', 's906787454', 's142322037']
[47404.0, 47532.0, 47496.0]
[192.0, 468.0, 359.0]
[597, 637, 600]
p02623
u693173434
2,000
1,048,576
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.
['import sys\nn,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nprog=0\na_idx=0\nb_idx=0\n\nwhile a_idx<n:\n if a[a_idx]+prog>k:\n break\n prog+=a[a_idx]\n a_idx+=1\n\nif a_idx==n:\n while b_idx<m:\n if b[b_idx]+prog>k:\n break\n prog+=b[b_idx]\n b_idx+=1\n\nmx=a_idx+b_idx\n\nif mx==n+m:\n print(mx)\n sys.exit()\n\nfor i in range(a_idx):\n while b[b_idx]+prog<=k or b_idx<m:\n prog+=b[b_idx]\n b_idx+=1\n if a_idx+b_idx>mx:\n mx=a_idx+b_idx\n if b_idx==m:\n break\n a_idx-=1\n prog-=a[a_idx]\n\nprint(mx)', 'import sys\nn,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nprog=0\na_idx=0\nb_idx=0\n\nwhile a_idx<n:\n if a[a_idx]+prog>k:\n break\n prog+=a[a_idx]\n a_idx+=1\n\nif a_idx==n:\n while b_idx<m:\n if b[b_idx]+prog>k:\n break\n prog+=b[b_idx]\n b_idx+=1\n\nmx=a_idx+b_idx\n\nif mx==n+m:\n print(mx)\n sys.exit()\n\nfor i in range(a_idx+1):\n while b_idx<m and b[b_idx]+prog<=k:\n prog+=b[b_idx]\n b_idx+=1\n if a_idx+b_idx>mx:\n mx=a_idx+b_idx\n if b_idx==m:\n break\n if a_idx==0:\n break\n a_idx-=1\n prog-=a[a_idx]\n\nprint(mx)']
['Runtime Error', 'Accepted']
['s444119758', 's576420267']
[40480.0, 40452.0]
[206.0, 295.0]
[616, 650]
p02623
u695261159
2,000
1,048,576
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.
['N,M,K= map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nif A[0] > K and B[0] > K:\n print(0)\n exit()\n\ntsundoku = [0]*(N+M)\ncurrentIndexA = 0\ncurrentIndexB = 0\nfor i in range(N+M+1):\n if currentIndexA >= N and currentIndexB < M:\n tsundoku[i] = tsundoku[i-1] + B[currentIndexB]\n currentIndexB += 1\n elif currentIndexB >= M and currentIndexA < N:\n tsundoku[i] = tsundoku[i-1] + A[currentIndexA]\n currentIndexA += 1\n elif currentIndexA >= N and currentIndexB >= M:\n print(i)\n exit()\n elif A[currentIndexA] < B[currentIndexB]:\n if i == 0:\n tsundoku[i] = A[currentIndexA]\n else:\n tsundoku[i] = tsundoku[i-1] + A[currentIndexA]\n currentIndexA += 1\n else:\n if i == 0:\n tsundoku[i] = B[currentIndexB]\n else:\n tsundoku[i] = tsundoku[i-1] + B[currentIndexB]\n currentIndexB += 1\n\n print(tsundoku[i])\n if tsundoku[i] > K:\n print(i)\n exit()', 'import bisect\nN,M,K= map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ndpA = [0]*(N+1)\ndpB = [0]*(M+1)\n\nfor i in range(1,N+1):\n dpA[i] = dpA[i-1] + A[i-1]\n\nfor i in range(1,M+1):\n dpB[i] = dpB[i-1] + B[i-1]\n\nans = 0\nfor i in range(N+1):\n if dpA[i] > K:\n continue\n indexB = bisect.bisect_right(dpB, K - dpA[i])\n ans = max(ans, i + indexB - 1)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s599071979', 's920147380']
[42000.0, 47460.0]
[425.0, 374.0]
[1044, 424]
p02623
u695474809
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nminute=0\nans=0\nfor _ in range(100000000):\n if not A and not B:break\n if not A: minute+=B[0]\n if not B: minute+=A[0]\n if A[0]<B[0]: \n del A[0]\n minute += min(A[0], B[0])\n elif B[0]<A[0]:\n del B[0]\n minute += min(A[0], B[0])\n else: \n del A[0]\n minute += min(A[0], B[0])\n if minute>K: break\n ans += 1\nprint(ans)\n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na,b = [0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s708400318', 's865410291']
[39560.0, 47692.0]
[2206.0, 304.0]
[472, 338]
p02623
u696444274
2,000
1,048,576
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.
['n, m, p = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n#\n\n# a = int(input())\n# w = list(map(int, input().split()))\n\n# a = list(map(int, input().split()))\n\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\n\n# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))\narui = [0]\nfor i in range(n):\n arui.append(arui[i]+a[i])\n\nbrui = [0]\nfor i in range(m):\n brui.append(brui[i]+b[i])\n\nans = 0\nfor i in range(1, n+1):\n if arui[i] > p:\n break\n bmax = p-arui[i]\n for j in range(m, -1, -1):\n \n if bmax >= brui[j]:\n if ans <= i+j:\n ans = i+j\n break\n\nprint(arui)\nprint(brui)\nprint(ans)\n', 'n, m, p = list(map(int, input().split()))\n# a = list(map(int, input().split()))\n#\n\n# a = int(input())\n# w = list(map(int, input().split()))\n\n# a = list(map(int, input().split()))\n\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\n\n# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))\narui = [0]\nfor i in range(n):\n arui.append(arui[i]+a[i])\n\nbrui = [0]\nfor i in range(m):\n brui.append(brui[i]+b[i])\n\nans = 0\nj = m\nfor i in range(n+1):\n if arui[i] > p:\n break\n bmax = p-arui[i]\n while brui[j] > bmax:\n j -= 1\n if ans <= i+j:\n ans = i+j\n\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s202430666', 's144170039']
[54776.0, 47432.0]
[2207.0, 278.0]
[979, 878]
p02623
u696499790
2,000
1,048,576
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.
['N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nfor i in range(1,N):\n A[i]+=A[i-1]\nfor i in range(1,M):\n B[i]+=B[i-1]\n\nj,best=0,0\nfor j in range(M):\n if B[j] > K: break\n else:best=j+1\nfor i in range(N):\n if A[i]>K:break\n c = K-A[i]\n while j < M:\n if B[j]> c:break\n else: j+=1\n if j==0:break\n else:\n best=max(best,i+1+j)\nprint(best)\n\n\n\n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nfor i in range(1,N):\n A[i]+=A[i-1]\nfor i in range(1,M):\n B[i]+=B[i-1]\n\nj,best=0,0\nfor j in range(M):\n if B[j] > K: break\n else:best=j+1\nj=0\nfor i in range(N):\n if A[i] > K: break\n while j < M:\n if A[i]+B[j] > K: break\n else: j+=1\n best=max(best,i+1+j)\nprint(best)\n\n\n\n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nfor i in range(1,N):\n A[i]+=A[i-1]\nfor i in range(1,M):\n B[i]+=B[i-1]\n\nj,best=0,0\nfor j in range(M):\n if B[j] > K: break\n else:best=j+1\nfor i in range(N):\n if A[i]>K:break\n c = K-A[i]\n while j < M:\n if B[j]> c:break\n else: j+=1\n \n best=max(best,i+1+j)\nprint(best)\n\n\n\n', 'N,M,K=map(int,input().split())\nA=[0]+list(map(int,input().split()))\nB=[0]+list(map(int,input().split()))\nfor i in range(1,N+1):\n A[i]+=A[i-1]\nfor i in range(1,M+1):\n B[i]+=B[i-1]\n\nbest=0\nj=M\nfor i in range(0,N+1):\n while j>0:\n if A[i]+B[j]<=K:\n break\n else: j-=1\n if A[i]+B[j]<=K:\n best=max(best,i+j)\n pass\nprint(best)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s474924173', 's747614755', 's965333668', 's544837499']
[40460.0, 8920.0, 40532.0, 39964.0]
[291.0, 25.0, 310.0, 316.0]
[402, 379, 379, 337]
p02623
u701513230
2,000
1,048,576
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.
['N,M,K = map(int,input().split())\n\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nsumA = sum(A)\n\nans = []\nprint(A,B)\n\nfor i in range(N):\n sumB = 0\n sumB = sum(B)\n for j in range(M):\n S = sumA + sumB\n sumB -= B[M-1-j]\n if S > K:\n continue\n else:\n ans.append(N+M-i-j)\n print(sumA,sumB)\n break\n sumA -= A[N-1-i]\n \nif ans == []:\n print(0)\nelse:\n print(max(ans))', 'N,M,K = map(int,input().split())\n\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nsumA = sum(A)\n\nans = []\nprint(A,B)\n\nfor i in range(N):\n sumB = 0\n sumB = sum(B)\n for j in range(M):\n S = sumA + sumB\n sumB -= B[M-1-j]\n if S > K:\n continue\n else:\n ans.append(N+M-i-j)\n break\n sumA -= A[N-1-i]\n \nif ans == []:\n print(0)\nelse:\n print(max(ans))', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = []\n\na = [0]\nfor i in range(N):\n a.append(a[i]+A[i])\nb = [0]\nfor i in range(M):\n b.append(b[i]+B[i])\n\ncen = M\nj = M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j -= 1\n ans.append(i+j)\n \nprint(max(ans))\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s151615503', 's733310824', 's652366796']
[40736.0, 40444.0, 48572.0]
[2211.0, 2211.0, 273.0]
[423, 400, 341]
p02623
u705418271
2,000
1,048,576
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.
['n,m,k=map(int,input().split())\na=[0]+list(map(int,input().split()))\nb=[0]+list(map(int,input().split()))\nfor i in range(1,n+1):\n a[i]+=a[i-1]\n\ni=n\ntotal=0\nans=0\nfor j in range(m+1):\n total+=b[j]\n while i>=0 and a[i]+total>k:\n i-=1\n if a[i]+total<=k:\n ans=max(ans,i+j)', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n \na=[0]\nb=[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \n#print(a)\n#print(b)\n \nans=0\nj=M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n #print(i,j)\n ans=max(ans,i+j)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s235602592', 's511818506']
[39944.0, 47356.0]
[287.0, 287.0]
[277, 364]
p02623
u709970295
2,000
1,048,576
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.
['from collections import deque\nimport numpy as np\nn,m,k = map(int,input().split())\nA = deque(map(int,input().split()))\nB = deque(map(int,input().split()))\n\na=[0]\nb = [0]\nfor i in range(n):\n a.append(a[i-1]+A[i])\nfor i in range(m):\n b.append(b[i-1]+B[i])\n\nx,j = 0,m\nfor i in range(n+1):\n if a[i]>k:\n break\n while b[j] > k-a[i]:\n j -=1\n x = max(x,i+j)\nprint(x)', 'from collections import deque\nimport numpy as np\nn,m,k = map(int,input().split())\nA = deque(map(int,input().split()))\nB = deque(map(int,input().split()))\n\na=[0]\nb = [0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\n\nx,j = 0,m\nfor i in range(n+1):\n if a[i]>k:\n break\n while b[j] > k-a[i]:\n j -=1\n x = max(x,i+j)\nprint(x)\n']
['Wrong Answer', 'Accepted']
['s165661364', 's163111170']
[66588.0, 66248.0]
[1606.0, 1534.0]
[386, 383]
p02623
u713492631
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(a[i] + A[i])\n\nans, j = o, M\n\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\n\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s096493251', 's002725850']
[47548.0, 47316.0]
[194.0, 309.0]
[364, 364]
p02623
u718949306
2,000
1,048,576
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.
['from collections import deque\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = N + M\ncnt = 0\nres = 0\nA = deque(A)\nB = deque(B)\nfor c in range(C):\n if A:\n a = A.popleft()\n else:\n a = 10**10+1\n if B:\n b = B.popleft()\n else:\n b = 10**10+1\n if a >= b:\n cnt += b\n A.appendleft(a)\n elif a <= b:\n cnt += a\n B.appendleft(b)\n\n if cnt < K:\n res += 1\n else:\n break', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na = [0]*(N+1)\nb = [0]*(M+1)\nX = 0\nY = 0\ncnt = 0\nfor n in range(N):\n a[n+1] = a[n] + A[n]\nfor n in range(M):\n b[n+1] = b[n] + B[n]\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\nwhile b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na = [0]*(N+1)\nb = [0]*(M+1)\nfor n in range(N):\n a[n+1] = a[n] + A[n]\nfor n in range(M):\n b[n+1] = b[n] + B[n]\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s499812327', 's683456394', 's781683468']
[42100.0, 48396.0, 46868.0]
[280.0, 343.0, 295.0]
[510, 382, 371]
p02623
u723345499
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_sum = [0]\nb_sum = [0]\nfor i in range(n):\n a_sum.append(a_sum[i] + a[i])\nfor i in range(m):\n b_sum.append(b_sum[j] + b[j])\n \nans, j = 0, m\nfor i in range(n + 1):\n if a_sum[i] > k:\n break\n while b_sum[i] > k - a_sum[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_sum = [0]\nb_sum = [0]\nfor i in range(n):\n a_sum.append(a_sum[i] + a[i])\nfor i in range(m):\n b_sum.append(b_sum[j] + b[j])\n \nans, j = 0, m\nfor i in range(n + 1):\n if a_sum[i] > k:\n break\n while b_sum[i] > k - a_sum[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_sum = [0]\nb_sum = [0]\nfor i in range(n):\n a_sum.append(a_sum[i] + a[i])\nfor i in range(m):\n b_sum.append(b_sum[j] + b[j])\n \nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[i] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_sum = [0]\nb_sum = [0]\nfor i in range(n):\n a_sum.append(a_sum[i] + a[i])\nfor i in range(m):\n b_sum.append(b_sum[i] + b[i])\n \nans, j = 0, m\nfor i in range(n + 1):\n if a_sum[i] > k:\n break\n while b_sum[j] > k - a_sum[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s209831996', 's407084005', 's848532474', 's433305940']
[40632.0, 40408.0, 40632.0, 47336.0]
[148.0, 151.0, 138.0, 305.0]
[402, 402, 390, 402]
p02623
u726823037
2,000
1,048,576
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.
['n,m,k = list(map(int,input().split()))\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nb = sum(B)\nka = k\ni = m\nre = 0\nfor a in A:\n if ka < 0:\n break\n while ka < b and i > 0:\n b -= B[i]\n i -= 1\n ka -= a\n re += 1\n \nprint(re+i)', 'n,m,k = list(map(int,input().split()))\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nb = sum(B)\nka = k\ni = m\nc = 0\nre = 0\nA.insert(0, 0)\nfor a in A:\n ka -= a\n if ka < 0:\n break\n while ka < b and i > 0:\n i -= 1\n b -= B[i]\n c += 1\n re = max(re, c+i)\n\n \nprint(re-1) ']
['Runtime Error', 'Accepted']
['s156828138', 's407770660']
[40552.0, 40544.0]
[137.0, 221.0]
[260, 303]
p02623
u731436822
2,000
1,048,576
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.
['# ABC C-Tsundoku\nn,m,k = map(int,input().split())\nan = list(map(int,input().split()))\nbn = list(map(int,input().split()))\n\nsuma = [0]\nsumb = [0]\na = 0\nb = 0\nfor i in an:\n a += i\n suma.append(a)\nfor i in bn:\n b += i\n sumb.append(b)\n\nres = [0]\nl = m\nfor j in range(n+1):\n if k-suma[j] < 0:\n break\n while k-suma[j]-sumb[l] < 0 and l > 0:\n l -= 1\n res.append(j+l-1)\nprint(max(res))', '# ABC C-Tsundoku\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nans = 0\nflag = False\nfor i in range(n+1):\n if flag == True:\n break\n for j in range(m+1):\n if sum(a[:i])+sum(b[:j])<=k and ans < i+j:\n ans = i+j\n flag = True\n break\nprint(ans)', '# ABC C-Tsundoku\nn,m,k = map(int,input().split())\nan = list(map(int,input().split()))\nbn = list(map(int,input().split()))\n\nsuma = [0]\nsumb = [0]\na = 0\nb = 0\nfor i in an:\n a += i\n suma.append(a)\nfor i in bn:\n b += i\n sumb.append(b)\n\nres = [0]\nfor j in range(n+1):\n if k-suma[j] < 0:\n break\n for l in range(m+1):\n if k-suma[j]-sumb[l] > 0:\n res.append(j+l)\nprint(max(res))', '# ABC C-Tsundoku\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nans = 0\nif sum(a)+sum(b) <= k:\n ans = n+m\n print(ans)\nelse:\n flag = False\n for i in range(n+1):\n if flag == True:\n break\n for j in range(m+1):\n if sum(a[:i])+sum(b[:j])<=k and ans < i+j:\n ans = i+j\n flag = True\n break\n print(ans)', '# ABC C-Tsundoku\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nans = 0\nif sum(a)+sum(b) <= k:\n ans = n+m\n print(ans)\nelse:\n flag = False\n for i in range(n+1):\n if flag == True:\n break\n for j in range(m+1):\n if sum(a[:i])+sum(b[:j])<=k and ans < i+j:\n ans = i+j\n flag = True\n break\n print(ans)', '# ABC C-Tsundoku\nimport sys\ninput = sys.stdin.readline\n\nn,m,k = map(int,input().split())\nan = list(map(int,input().split()))\nbn = list(map(int,input().split()))\n\nsuma = [0]\nsumb = [0]\na = 0\nb = 0\nfor i in an:\n a += i\n suma.append(a)\nfor i in bn:\n b += i\n sumb.append(b)\n\nres = [0]\nl = m\nfor j in range(n+1):\n if k-suma[j] < 0:\n break\n while k-suma[j]-sumb[l] < 0 and l > 0:\n l -= 1\n res.append(j+l)\nprint(max(res))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s526334697', 's884072039', 's913681157', 's913719113', 's926572399', 's706583705']
[49700.0, 40440.0, 9040.0, 40620.0, 40648.0, 50684.0]
[279.0, 2206.0, 26.0, 2206.0, 2206.0, 282.0]
[412, 348, 409, 446, 446, 449]
p02623
u733866054
2,000
1,048,576
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.
['import sys\nN,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=A+B\nd=0\nC.sort()\nif sum(C)<=K :\n print(len(C))\n sys.exit()\nfor i in range(len(C)) :\n d=d+C[i]\n if d>K :\n print(i+1)\n sys.exit()', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na=[0]\nb=[0]\n\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\nj=M\nans=0\nfor i in range(N+1):\n if a[i]>K: \n break\n while b[j]>K-a[i] : \n j-=1 \n ans=max(ans,i+j)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s746250317', 's436823533']
[40760.0, 47648.0]
[302.0, 295.0]
[263, 493]
p02623
u734423776
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nc = 0\nwhile K > 0:\n if not A == [] and not B == []:\n if A[0] >= B[0]:\n K = K - A[0]\n A.remove(A[0])\n if K >= 0:\n c += 1\n else:\n K = K - B[0]\n B.remove(B[0])\n if K >= 0:\n c += 1\n if A == []:\n K = K - B[0]\n B.remove(B[0])\n if K >= 0:\n c += 1\n if B == []:\n K = K - A[0]\n A.remove(A[0])\n if K >= 0:\n c += 1\nprint(c)', 'N, M, K = map(int, input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nc = 0\nwhile K > 0:\n if not A == [] and not B == []:\n if A[0] >= B[0]:\n K = K - A[0]\n A.remove(A[0])\n if K >= 0:\n c += 1\n else:\n K = K - B[0]\n B.remove(B[0])\n if K >= 0:\n c += 1\n if A == []:\n K = K - B[0]\n B.remove(B[0])\n if K >= 0:\n c += 1\n if B == []:\n K = K - A[0]\n A.remove(A[0])\n if K >= 0:\n c += 1\nprint(c)', 'N, M, K = map(int, input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor j in range(M):\n b.append(b[j] + B[j])\n\nans = 0\nj = M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j = j -1\n ans = max(ans, i+j)\n \nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s040489334', 's168065422', 's985811759']
[41644.0, 41748.0, 47328.0]
[2206.0, 2206.0, 307.0]
[608, 600, 363]
p02623
u735891571
2,000
1,048,576
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.
['import itertools\nimport bisect\nN, M, K = map(int,input().split())\nA = list(map(int, input().split())) \nB = list(map(int, input().split())) \n\nA_ = list(itertools.accumulate(A))\nB_ = list(itertools.accumulate(B))\n\n\nl = len(A_)\nans = max(ans, bisect.bisect_right(B_, K))\nfor idx, i in enumerate(A_):\n if i <= K:\n ans = max(idx+1 + bisect.bisect_right(B_, K-i), ans)\n \nprint(ans)', 'import itertools\nimport bisect\nN, M, K = map(int,input().split())\nA = list(map(int, input().split())) \nB = list(map(int, input().split())) \n\nA_ = list(itertools.accumulate(A))\nB_ = list(itertools.accumulate(B))\n\nans = 0\nl = len(A_)\nans = max(ans, bisect.bisect_right(B_, K))\nfor idx, i in enumerate(A_):\n if i <= K:\n ans = max(idx+1 + bisect.bisect_right(B_, K-i), ans)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s956410072', 's718717486']
[47384.0, 47524.0]
[146.0, 289.0]
[386, 393]
p02623
u736470924
2,000
1,048,576
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.
['def resolve():\n import numpy as np\n\n N, M, K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n A_cumsum = np.cumsum(A)\n B_cumsum = np.cumsum(B)\n\n ans = 0\n j = M\n for i in range(N + 1):\n if A_cumsum[i] > K:\n break\n while A_cumsum[i] + B_cumsum[j] > K:\n j -= 1\n\n ans = max(ans, i + j)\n\n print(ans)\n\nresolve()', 'def resolve():\n import numpy as np\n\n N, M, K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n A = np.insert(np.cumsum(A), 0, 0)\n B = np.insert(np.cumsum(B), 0, 0)\n\n ans = 0\n j = M\n for i in range(N + 1):\n if A[i] > K:\n break\n while A[i] + B[j] > K:\n j -= 1\n\n ans = max(ans, i + j)\n\n print(ans)\n\nresolve()\n']
['Runtime Error', 'Accepted']
['s519693319', 's435954364']
[58600.0, 58736.0]
[241.0, 488.0]
[433, 433]
p02623
u739843002
2,000
1,048,576
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.
['def getIntList(strList):\n return list(map(lambda x: int(x), strList))\n\nN, M, K = getIntList(input().split(" "))\nA = getIntList(input().split(" "))\nB = getIntList(input().split(" "))\n\nTA = 0\nT = [0]\ncnt = [] # idx = n of B books\n\nfor i in range(len(A)):\n TA += A[i]\n if TA <= K:\n T.append(TA)\n else:\n break\n\ncnt.append(len(T) - 1)\n\nfor j in range(len(B)):\n print(T)\n print(cnt)\n T = list(filter(lambda t: t<= K, list(map(lambda t: t + B[j], T))))\n cnt.append(len(T) - 1)\n if len(T) <= 0:\n break\n\nfor k in range(len(cnt)):\n cnt[k] += k\n\nprint(max(cnt))', 'def getIntList(strList):\n return list(map(lambda x: int(x), strList))\n\nN, M, K = getIntList(input().split(" "))\nA = getIntList(input().split(" "))\nB = getIntList(input().split(" "))\n\nta = 0\ntb = 0\nTA = [0]\nTB = [0]\n\nfor i in range(len(A)):\n ta += A[i]\n if ta <= K:\n TA.append(ta)\n else:\n break\nfor j in range(len(B)):\n tb += B[j]\n if tb <= K:\n TB.append(tb)\n else:\n break\n\nCij = [0]\n\nj = len(TB) - 1\nfor i in range(len(TA)):\n while TA[i] + TB[j] > K:\n j += -1\n else:\n if j >= 0:\n Cij.append(i + j)\n if j == -1:\n break\n\n\nprint(max(Cij))\n']
['Wrong Answer', 'Accepted']
['s960454139', 's566021980']
[139848.0, 49964.0]
[2336.0, 313.0]
[569, 572]
p02623
u744920373
2,000
1,048,576
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.
["import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\nimport bisect \n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \n'''\nN, M , lim = mi()\n\nA = li()\nB = li()\n\nA += [10**9+1]\nB += [10**9+1]\nind_a = 0 \nind_b = 0\n\ncnt = ans = 0\n\nwhile True:\n if A[ind_a] > B[ind_b]:\n if cnt + B[ind_b] <= lim:\n ans += 1\n cnt += B[ind_b]\n if ind_b != M:\n ind_b += 1\n else:\n break\n\n elif A[ind_a] < B[ind_b]:\n if cnt + A[ind_a] <= lim:\n ans += 1\n cnt += A[ind_a]\n if ind_a != N:\n ind_a += 1\n else:\n break\n\n else:\n if ind_a == N and ind_b == M:\n break\n elif ind_a == N:\n if cnt + B[ind_b] <= lim:\n ans += 1\n cnt += B[ind_b]\n if ind_b != M:\n ind_b += 1\n else:\n break\n elif ind_b == M:\n if cnt + A[ind_a] <= lim:\n ans += 1\n cnt += A[ind_a]\n if ind_a != N:\n ind_a += 1\n else:\n break\n else:\n if A[ind_a+1] >= B[ind_b+1]:\n if cnt + B[ind_b] <= lim:\n ans += 1\n cnt += B[ind_b]\n if ind_b != M:\n ind_b += 1\n else:\n break\n else:\n if cnt + A[ind_a] <= lim:\n ans += 1\n cnt += A[ind_a]\n if ind_a != N:\n ind_a += 1\n else:\n break\n\nprint(ans)\n'''\nN, M , lim = mi()\n\nA = li()\nB = li()\n\nA = [0] + list(accumulate(A))\nB = list(accumulate(B))\nans = 0\n\nfor i in range(N+1):\n ind = bisect.bisect_right(B, max(lim-A[i], 0))\n print(i, ind)\n if ind > 0 or lim-A[i] == 0:\n ans = max(ans, ind + i)\n\nprint(ans)", "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\nimport bisect \n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \n\nN, M, lim = mi()\nA = li()\nB = li()\n\nA = [0] + list(accumulate(A))\nB = [0] + list(accumulate(B))\nans = 0\n'''\nfor i in range(N+1):\n if lim < A[i]:\n continue\n #right = 0\n cnt = 0\n wa = 0\n\n while right < M and wa + B[right] <= lim - A[i]:\n wa += B[right]\n right += 1\n\n cnt = right - left\n\n if cnt > 0:\n ans = max(ans, cnt+i)\n\nprint(ans)\n'''\nright = M\n\nfor i in range(N+1):\n if A[i] > lim:\n continue\n\n while True:\n if right < 0 or A[i] + B[right] <= lim:\n break\n right -= 1\n \n #print(i, right)\n ans = max(ans, i + right)\n \nprint(ans)"]
['Wrong Answer', 'Accepted']
['s276440065', 's907697419']
[42892.0, 41056.0]
[418.0, 261.0]
[2409, 1202]
p02623
u752907966
2,000
1,048,576
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.
['n,m,K = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\n\nsa = [0]*len(a)\nsa[0] = a[0]\nfor i,k in enumerate(a):\n if i == 0:continue\n sa[i] = sa[i-1] + a[i]\nsb = [0]*len(b)\nsb[0] = b[0]\nfor i,k in enumerate(b):\n if i == 0:continue\n sb[i] = sb[i-1] + b[i]\n\nai = len(a)-1\nbi = len(b)-1\n\nminu = sa[ai] + sb[bi]\nwhile(minu > K):\n if (sa[ai] - sa[ai-1]) > (sb[bi] - sb[bi-1]):\n ai -= 1\n minu = sa[ai] + sb[bi]\n else:\n bi -= 1\n minu = sa[ai] + sb[bi]\n\nprint(sa)\nprint(sb)\nprint(ai + bi + 2)\n', 'n,m,K = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\n\nsa = [0]*len(a)\nsa[0] = a[0]\nfor i,k in enumerate(a):\n if i == 0:continue\n sa[i] = sa[i-1] + a[i]\nsb = [0]*len(b)\nsb[0] = b[0]\nfor i,k in enumerate(b):\n if i == 0:continue\n sb[i] = sb[i-1] + b[i]\n\nai = len(a)-1\nbi = len(b)-1\n\nminu = sa[ai] + sb[bi]\nwhile(minu > K):\n if (sa[ai] - sa[ai-1]) > (sb[bi] - sb[bi-1]):\n ai -= 1\n minu = sa[ai] + sb[bi]\n else:\n bi -= 1\n minu = sa[ai] + sb[bi]\n\nprint(ai + bi + 2)\n', 'n,m,K = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\n\nsa = [0]\nsb = [0]\nfor i in range(n):\n sa.append(sa[i]+a[i])\nfor i in range(m):\n sb.append(sb[i]+b[i])\n \n\nans = 0\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[m] > k - a[i]:\n m -= 1\n ans = max(ans,i+m)\nprint(ans)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\n\nsa = [0]\nsb = [0]\nfor i in range(n):\n sa.append(sa[i]+a[i])\nfor i in range(m):\n sb.append(sb[i]+b[i])\n\n\nans = 0\nfor i in range(n+1):\n if sa[i] > k:\n break\n while sb[m] > k - sa[i]:\n m -= 1\n ans = max(ans,i+m)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s431059398', 's532514247', 's766430458', 's789351566']
[47488.0, 48508.0, 47452.0, 47348.0]
[483.0, 491.0, 203.0, 306.0]
[587, 567, 425, 425]
p02623
u753971348
2,000
1,048,576
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.
['a = input()\nn = input()\nm = input()\nfirst = a.split(" ")\nN = n.split(" ")\nM = m.split(" ")\noverflow = 0\nfor i in N:\n if int(i) >= 10**9:\n overflow = 1\n break\n \nfor i in M:\n if int(i) >= 10**9:\n overflow = 1\n break\nif first[0] >= 200000 or first[1] >= 200000:\n overflow = 1\nif first[2] >= 10**9:\n overflow = 1\n \nif overflow == 0:\n totaltime = 0\n count = 1\n for i in range(int(first[1]) + int(first[0])):\n if i == 6:\n break\n if len(N) != 0 and len(M) != 0:\n if totaltime + int(N[0]) > int(first[2]) or totaltime + int(M[0]) > int(first[2]):\n break\n if len(N) == 0:\n totaltime += int(M[0])\n M.remove(M[0])\n count += 1\n if totaltime > int(first[2]):\n break\n elif len(M) == 0:\n totaltime += int(N[0])\n N.remove(N[0])\n count += 1\n if totaltime > int(first[2]):\n break\n elif int(N[0]) < int(M[0]):\n totaltime += int(N[0])\n N.remove(N[0])\n count += 1\n elif int(M[0]) < int(N[0]):\n totaltime += int(M[0])\n M.remove(M[0])\n count += 1\n print(count)\nelse:\n print(0)', 'a,n,m = input(), input(), input()\nfirst = a.split(" ")\nN = n.split(" ")\nM = m.split(" ")\noverflow = 0\nfor i in N:\n if int(i) >= 10**9:\n overflow = 1\n break\n \nfor i in M:\n if int(i) >= 10**9:\n overflow = 1\n break\n \nif int(first[0]) >= 200000 or int(first[1]) >= 200000:\n overflow = 1\nif int(first[2]) >= 10**9:\n overflow = 1\n \nif overflow == 0:\n totaltime = 0\n count = 0\n for i in range(int(first[1]) + int(first[0])):\n if len(N) == 0:\n totaltime += int(M[0])\n M.remove(M[0])\n count += 1\n elif len(M) == 0:\n totaltime += int(N[0])\n N.remove(N[0])\n count += 1\n elif int(N[0]) < int(M[0]):\n totaltime += int(N[0])\n N.remove(N[0])\n count += 1\n elif int(M[0]) < int(N[0]):\n totaltime += int(M[0])\n M.remove(M[0])\n count += 1\n if len(M) > 1 and len(N) > 1:\n if totaltime + min(int(N[0]),int(M[0])) > int(first[2]):\n break\n else:\n if totaltime > int(first[2]):\n break\n print(count)\nelse:\n print(0)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int,input().split()))\na,b = [0],[0]\nfor i in range(N):\n a.append(a[i] + A[i])\n \nfor i in range(M):\n b.append(b[i] + B[i])\nprint(a)\nprint(b)\n\ntotaltime = 0\ncount,j = 0, M\n\nfor i in range(N+1):\n if a[i] > K:\n break\n while a[i] + b[j] > K:\n j -= 1\n count = max(count,i + j)\n\nprint(count)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int,input().split()))\na,b = [0],[0]\nfor i in range(N):\n a.append(a[i] + A[i])\n \nfor i in range(M):\n b.append(b[i] + B[i])\ntotaltime = 0\ncount,j = 0, M\n \nfor i in range(N+1):\n if a[i] > K:\n break\n while a[i] + b[j] > K:\n j -= 1\n count = max(count,i + j)\n \nprint(count)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s368944554', 's778601866', 's965034943', 's711502978']
[41520.0, 41576.0, 54472.0, 47552.0]
[146.0, 1186.0, 317.0, 301.0]
[1193, 1121, 401, 384]
p02623
u755180064
2,000
1,048,576
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.
["\ndef main():\n n, m, k = list(map(int, input().split()))\n a_books = list(map(int, input().split()))\n b_books = list(map(int, input().split()))\n a_idx = -1\n b_idx = -1\n sumbooks = sum(a_books) + sum(b_books)\n count = len(a_books) + len(b_books)\n if a_books[0] > k and b_books[0] > k:\n print(0)\n exit()\n elif sumbooks <= k:\n print(len(a_books) + len(b_books))\n exit()\n\n while sumbooks > k:\n # print(sumbooks, a_idx, b_idx)\n\n if b_idx >= len(b_books)*-1 and a_idx >= len(a_books)*-1:\n break\n elif b_idx >= len(b_books)*-1 or (a_idx < len(a_books)*-1 and a_books[a_idx] < b_books[b_idx]):\n sumbooks += a_books[a_idx]\n a_idx += -1\n elif a_idx >= len(a_books)*-1 or (b_idx < len(b_books)*-1 and b_books[b_idx] < a_books[a_idx]):\n sumbooks += b_books[b_idx]\n b_idx += -1\n if sumbooks <= k:\n break\n count += 1\n print(count)\n\n\nif __name__ == '__main__':\n main()\n", "def main2():\n n, m, k = list(map(int, input().split()))\n a_books = list(map(int, input().split()))\n b_books = list(map(int, input().split()))\n\n a, b = [0], [0]\n \n for i in range(len(a_books)):\n a.append(a[i] + a_books[i])\n\n for i in range(len(b_books)):\n b.append(b[i] + b_books[i])\n ans, j = 0, len(b_books)\n \n for i in range(len(a)):\n if a[i] > k :\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\n print(ans)\n\n\nif __name__ == '__main__':\n main2()\n\n"]
['Wrong Answer', 'Accepted']
['s759808989', 's647515996']
[41156.0, 47548.0]
[113.0, 226.0]
[1024, 556]
p02623
u756279759
2,000
1,048,576
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.
['N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n \na,b = [0],[0]\nfor i in range(N):\n a.append(a[i]+A[i]\nfor i in range(M):\n b.append(b[i]+B[i])\n \nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break \n while b[j]>K-a[i]:\n j -= 1 \n ans = max(ans,i+j)\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n \na,b = [0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break \n while b[j]>K-a[i]:\n j -= 1 \n ans = max(ans,i+j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s504589065', 's976560066']
[8864.0, 47376.0]
[31.0, 290.0]
[346, 348]
p02623
u757117214
2,000
1,048,576
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.
['import numpy as np\n\nN,M,K = map(int,input().split())\nA = np.array(input().split(),dtype=int)\nB = np.array(input().split(),dtype=int)\n\nAA = np.insert(A,0,0)\nBB = np.insert(B,0,0)\nAAA = np.cumsum(AA)\nBBB = np.cumsum(BB)\nmax_mins = 0\nmax_books = 0\nfor a in enumerate(AAA):\n if a[1] > K:\n break\n for b in enumerate(BBB):\n if a[2] + b[1] > K:\n break\n if a[0] + b[0] > max_books:\n max_books = a[0] + b[0]\nprint(max_books) \n', 'import numpy as np\nfrom bisect import bisect\n\nN,M,K = map(int,input().split())\nA = np.array(input().split(),dtype=int)\nB = np.array(input().split(),dtype=int)\n\nAA = np.insert(A,0,0)\nBB = np.insert(B,0,0)\nAAA = np.cumsum(AA)\nBBB = np.cumsum(BB)\nmax_books = 0\nfor a in enumerate(AAA):\n if a[1] > K:\n break\n books = a[0]\n ind = bisect(BBB,K - a[1])\n books += (ind-1)\n max_books = max(books,max_books)\nprint(max_books) \n \n \n']
['Runtime Error', 'Accepted']
['s788341563', 's720750902']
[56864.0, 56624.0]
[222.0, 714.0]
[477, 455]
p02623
u760527120
2,000
1,048,576
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.
['import numpy as np\nn, m, k = [int(n) for n in input().split()]\nA = [int(n) for n in input().split()]\nB = [int(n) for n in input().split()]\n\nA = [a for a in np.cumsum([0] + A) if a <= k]\nB = [b for b in np.cumsum([0] + B) if b <= k]\nB, A = sorted((A, B), key=len)\nfor i, a in enumerate(A[::-1]):\n for j, b in enumerate(B[::-1]):\n if a + b <= k:\n n_read = len(A) + len(B) - i - j - 2\n break\n if a + b <= k:\n break\nprint(n_read)', '@profile\ndef main():\n from numpy import cumsum\n n, m, k = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n A = cumsum([0] + A)\n B = cumsum([0] + B)\n n_read = 0\n b_tail = B[-1]\n for i, a in enumerate(A):\n if a > k:\n break\n j = m\n if b_tail + a > k:\n for j, b in enumerate(B):\n if a + b > k:\n break\n n_read = max(n_read, i + j)\n print(n_read)\nmain()\n', 'from numpy import cumsum\nn, m, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA = cumsum([0] + A)\nB = cumsum([0] + B)\nn_read = 0\nb_tail = B[-1]\nfor i, a in enumerate(A):\n if a > k:\n break\n j = m\n if b_tail + a > k:\n for j, b in enumerate(B):\n if a + b > k:\n break\n n_read = max(n_read, i + j)\nprint(n_read)\n', 'from numpy import cumsum\nn, m, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA = cumsum([0] + A)\nB = cumsum([0] + B)\nn_read = 0\nl = len(B) - 1\nfor i, a in enumerate(A):\n if a > k:\n break\n for j, b in enumerate(B[l::-1]):\n if a + b <= k:\n l -= j\n n_read = max(n_read, i + l)\n break\nprint(n_read)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s403669398', 's833996176', 's907228248', 's056474844']
[57564.0, 8996.0, 58504.0, 58452.0]
[402.0, 26.0, 2206.0, 541.0]
[468, 521, 421, 410]
p02623
u760961723
2,000
1,048,576
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.
["import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\ninput = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\ndef main():\n N, M, K = NMI()\n A = NLI()\n B = NLI()\n \n cumsum_A = [0 for _ in range(len(A)+1)]\n cumsum_B = [0 for _ in range(len(B)+1)] \n \n cnt = 0\n \n for n in range(N):\n cnt += A[n]\n cumsum_A[n+1] = cnt\n \n cnt = 0\n \n for m in range(M):\n cnt += B[m]\n cumsum_B[m+1] = cnt\n \n\n \n ans = 0\n \n for n in range(N+1):\n remain_K = K - cumsum_A[n]\n if remain_K < 0:\n break\n else:\n for m in range(M,-1,-1):\n if cumsum_B[m]> remain_K:\n continue\n else:\n print(ans,n,m)\n ans = max(ans,n+m)\n break\n \n print(ans)\n \n \n\n\nif __name__ == '__main__':\n main()", "import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\ninput = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\ndef main():\n N, M, K = NMI()\n A = NLI()\n B = NLI()\n \n cumsum_A = [0 for _ in range(len(A)+1)]\n cumsum_B = [0 for _ in range(len(B)+1)] \n \n cnt = 0\n \n for n in range(N):\n cnt += A[n]\n cumsum_A[n+1] = cnt\n \n cnt = 0\n \n for m in range(M):\n cnt += B[m]\n cumsum_B[m+1] = cnt\n \n\n \n ans = 0\n b= M\n \n for n in range(N+1):\n remain_K = K - cumsum_A[n]\n if remain_K < 0:\n break\n else:\n for m in range(b,-1,-1):\n if cumsum_B[m]> remain_K:\n continue\n else:\n b = m\n ans = max(ans,n+m)\n break\n \n print(ans)\n \n \n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s231862587', 's027969390']
[47768.0, 47992.0]
[2210.0, 265.0]
[1094, 1094]
p02623
u764956288
2,000
1,048,576
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.
['import sys\nsys.setrecursionlimit(10**1000000000)\n\n# readline = sys.stdin.readline\n# generator = (readline().strip() for _ in range(N))\n\n# N, M = map(int, input().split())\n# As = list(map(int, input().split()))\n# queries = (input() for _ in range(N))\n\n\ndef solve():\n N, M, K = map(int, input().split())\n\n As = list(map(int, input().split()))\n Bs = list(map(int, input().split()))\n\n def dfs(n, m, total, count):\n if total > K:\n return count - 1\n\n if n == N and m == M:\n return count\n\n if n < N:\n c1 = dfs(n+1, m, total+As[n], count+1)\n else:\n c1 = count\n\n if m < M:\n c2 = dfs(n, m+1, total+Bs[m], count+1)\n else:\n c2 = count\n\n return max(c1, c2)\n\n return dfs(0, 0, 0, 0)\n\n\ndef main():\n print(solve())\n\n\nif __name__ == "__main__":\n main()\n', 'from itertools import chain\n\n\ndef solve():\n N, M, K = map(int, input().split())\n\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n answer = 0\n\n sum_b = sum(B)\n idx_b = M\n remain = K\n\n for i, a in enumerate(chain([0], A)):\n remain -= a\n if remain < 0:\n break\n\n while sum_b > remain and idx_b >= 0:\n idx_b -= 1\n b = B[idx_b]\n sum_b -= b\n\n i += idx_b\n answer = i if answer < i else answer\n\n return answer\n\n\ndef main():\n print(solve)\n\n\nif __name__ == "__main__":\n main()\n', 'from itertools import chain\n\n\ndef solve():\n N, M, K = map(int, input().split())\n\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n answer = 0\n\n sum_b = sum(B)\n idx_b = M\n remain = K\n\n for i, a in enumerate(chain([0], A)):\n remain -= a\n if remain < 0:\n break\n\n while sum_b > remain and idx_b >= 0:\n idx_b -= 1\n b = B[idx_b]\n sum_b -= b\n\n i += idx_b\n answer = i if answer < i else answer\n\n return answer\n\n\ndef main():\n print(solve())\n\n\nif __name__ == "__main__":\n main()\n']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s586909328', 's720743740', 's972388429']
[17960.0, 9048.0, 41140.0]
[2206.0, 29.0, 153.0]
[872, 605, 607]
p02623
u771007149
2,000
1,048,576
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.
["#C\nfrom itertools import accumulate\nimport bisect\n\nn,m,k = map(int,input().split())\na = deque(map(int,input().split()))\nb = deque(map(int,input().split()))\n\ncnt = 0\n\na_c = list(accumulate(list(a)))\nb_c = list(accumulate(list(b)))\nresult = []\n\nidx_a = bisect.bisect_left(a_c,k)\nidx_a_b = bisect.bisect_left(b_c,k-list(a)[idx_a])\nresult.append(idx_a + idx_a_b)\n\nidx_b = bisect.bisect_left(b_c,k)\nidx_b_a = bisect.bisect_left(a_c,k-list(b)[idx_b])\nresult.append(idx_b + idx_b_a)\n\nfor i in range(n+m):\n if len(a) > 0 and len(b) > 0:\n s,t = a.popleft(),b.popleft()\n elif len(a) > 0:\n s = a.popleft()\n t = float('inf')\n elif len(b) > 0:\n s = float('inf')\n t = b.popleft()\n else:\n break\n if s >= t:\n k -= t\n a.appendleft(s)\n else:\n k -= s\n b.appendleft(t)\n if k < 0:\n break\n else:\n cnt += 1\n #print('a:',a)\n #print('b:',b)\n \nresult.append(cnt)\n\nprint(min(result))", '#C\nfrom itertools import accumulate\nfrom collections import deque\nimport bisect\n\nn,m,k = map(int,input().split())\na = [0] + list(map(int,input().split()))\nb = [0] + list(map(int,input().split()))\n\ncnt = 0\n\na_c = list(accumulate(list(a)))\nb_c = list(accumulate(list(b)))\nresult = []\n\nfor i in range(n+1):\n if a_c[i] > k:\n continue\n b_idx = bisect.bisect_left(b_c,k-a_c[i]+1)\n result.append(i+b_idx-1)\n \nprint(max(result))\n']
['Runtime Error', 'Accepted']
['s964486901', 's906403341']
[9084.0, 51232.0]
[29.0, 294.0]
[981, 440]
p02623
u773081031
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\n\nfor i in range(N):\n\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n \nfor i in range(N):\n\ta.append(a[i] + A[i])\n \nfor i in range(M):\n\tb.append(b[i] + B[i])\n \nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s613655618', 's575719100']
[8988.0, 47656.0]
[23.0, 282.0]
[333, 346]
p02623
u779170803
2,000
1,048,576
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.
["INT = lambda: int(input())\nINTM = lambda: map(int,input().split())\nSTRM = lambda: map(str,input().split())\nSTR = lambda: str(input())\nLIST = lambda: list(map(int,input().split()))\nLISTS = lambda: list(map(str,input().split()))\ndef do(): \n n,m,k=INTM()\n A=LIST()\n B=LIST()\n As=[0]*(n+1)\n Bs=[0]*(m+1)\n ans=0\n for i in range(n):\n As[i+1]=As[i]+A[i]\n A=As\n for i in range(m):\n Bs[i+1]=Bs[i]+B[i]\n B=Bs\n \n\n if A[-1]+B[-1]<=k:\n ans=n+m\n\n b_s=m\n\n for i in range(n+1):\n\n if A[i]>k:\n #print(i)\n temp=i-1\n ans=max(ans,temp)\n break\n for i2 in range(b_s,-1,-1):\n #print(i,i2)\n #print(A[i]+B[i2])\n if A[i]+B[i2]<k:\n temp=i+i2-1\n b_s=i2\n #print(ans,temp)\n ans=max(ans,temp)\n break\n \n\n \n print(ans)\n\nif __name__ == '__main__':\n do()", "INT = lambda: int(input())\nINTM = lambda: map(int,input().split())\nSTRM = lambda: map(str,input().split())\nSTR = lambda: str(input())\nLIST = lambda: list(map(int,input().split()))\nLISTS = lambda: list(map(str,input().split()))\ndef do(): \n n,m,k=INTM()\n A=LIST()\n B=LIST()\n As=[0]*(n+1)\n Bs=[0]*(m+1)\n ans=0\n for i in range(n):\n As[i+1]=As[i]+A[i]\n A=As\n for i in range(m):\n Bs[i+1]=Bs[i]+B[i]\n B=Bs\n \n\n if A[-1]+B[-1]<=k:\n ans=n+m\n\n b_s=m\n\n for i in range(n+1):\n\n if A[i]>k:\n #print(i)\n temp=i-1\n ans=max(ans,temp)\n break\n for i2 in range(b_s,-1,-1):\n #print(i,i2)\n #print(A[i]+B[i2])\n if A[i]+B[i2]<=k:\n temp=i+i2\n b_s=i2\n #print(ans,temp)\n ans=max(ans,temp)\n break\n \n\n \n print(ans)\n\nif __name__ == '__main__':\n do()"]
['Wrong Answer', 'Accepted']
['s200888620', 's735928253']
[41044.0, 41192.0]
[262.0, 263.0]
[974, 973]
p02623
u785573018
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = [0]\nd = [0]\nfor i in range(n):\n c.append(a[i]+c[i])\nfor i in range)m:\n d.append(b[i]+d[i])\ne = 0\nfor i in range(n+1):\n if a[i] > k:\n break;\n while b[m] > k-a[i]:\n m -= 1\n e = max(e, i+m)\nprint(e)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = [0]\nd = [0]\nfor i in range(n):\n c.append(a[i]+c[i])\nfor i in range(m):\n d.append(b[i]+d[i])\ne = 0\nfor i in range(n+1):\n if a[i] > k:\n break;\n while b[m] > k-a[i]:\n m -= 1\n e = max(e, i+m)\nprint(e)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = [0]\nd = [0]\nfor i in range(n):\n c.append(a[i]+c[i])\nfor i in range(m):\n d.append(b[i]+d[i])\ne = 0\nfor i in range(n+1):\n if c[i] > k:\n break;\n while c[i]+d[m] > k:\n m -= 1\n e = max(e, i+m)\nprint(e)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s650820468', 's706980236', 's783524117']
[8980.0, 47364.0, 47340.0]
[22.0, 190.0, 285.0]
[336, 337, 337]
p02623
u790476785
2,000
1,048,576
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.
['n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ncount = 0\nnow_a = 0\nnow_b = 0\nwhile k > 0 and a[now_a] < k or b[now_b] < k:\n if a[0] > b[0] and now_a > len(a) or now_b < len(b):\n k -= b[now_b]\n now_b += 1\n else:\n k -= a[now_a]\n now_a += 1\n count += 1\n \nprint (count)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\n_sum = 0\n\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n \nj = m\ncounts = [0]\nfor i in range(n + 1):\n if (a[i] > k):\n break\n while b[j] > k - a[i]:\n j -= 1\n counts.append(i + j)\n \nprint (max(counts))']
['Runtime Error', 'Accepted']
['s625818753', 's382671545']
[40600.0, 48808.0]
[299.0, 276.0]
[341, 373]
p02623
u791449906
2,000
1,048,576
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.
['n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\na_sum = [0]\nfor i, minute in enumerate(a):\n a_sum.append(a_sum(i)+minute)\nb_sum = [0]\nfor i, minute in enumerate(b):\n b_sum.append(b_sum(i)+minute)\n\nB = m\nans_list = []\n\nfor i in a_sum:\n if i > k:\n ans_list.append(i)\n continue\n for j in b_sum[::-1]:\n if j <= k-i:\n ans_list.append(i+B)\n break\n elif j > k-i:\n B -= 1\n\nprint(max(ans_list))\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\n\nans, j = 0, M\n\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\na_sum = [0]\nfor i, minute in enumerate(a):\n a_sum.append(a_sum[i]+minute)\nb_sum = [0]\nfor i, minute in enumerate(b):\n b_sum.append(b_sum[i]+minute)\n\nB = m\nans_list = []\n\nfor i, a_time in enumerate(a_sum):\n if a_time > k:\n ans_list.append(i-1) \n break\n for j in b_sum[::-1]:\n if j <= k-a_time:\n ans_list.append(i+B)\n break\n elif j > k-a_time:\n B -= 1\nprint(max(ans_list))\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0],[0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\n\nans, j = 0, M\n\nfor i in range(N+i):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)\n', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\na_sum = [0]\nfor i, minute in enumerate(a):\n a_sum.append(a_sum[i]+minute)\nb_sum = [0]\nfor i, minute in enumerate(b):\n b_sum.append(b_sum[i]+minute)\n\nB = m\nans_list = []\n\nfor i, a_time in enumerate(a_sum):\n if a_time > k:\n ans_list.append(i-1) \n break\n for j in b_sum[::-1]:\n if j <= k-a_time:\n ans_list.append(i+B)\n break\n elif j > k-a_time:\n B -= 1\nprint(ans_list)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans, j = 0, M\n\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s362790161', 's552362525', 's577934325', 's605853088', 's926822533', 's697641592']
[42300.0, 40440.0, 49088.0, 40384.0, 48904.0, 47552.0]
[115.0, 113.0, 2207.0, 109.0, 2207.0, 275.0]
[612, 392, 681, 392, 676, 393]
p02623
u796878730
2,000
1,048,576
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.
['N,M,K = map(int,input().split(" "))\n\nA = list(map(int,input().split(" ")))\nB = list(map(int,input().split(" ")))\n\ntime_A = [0]*(N+1)\ntime_B = [0]*(M+1)\n\nfor i in range(N):\n time_A[i+1] = time_A[i] + A[i]\nprint(time_A)\nfor j in range(M):\n time_B[j+1] = time_B[j] + B[j]\n\nans = 0\nl = M\n\nfor k in range(N+1):\n if time_A[k] > K:\n break\n while time_A[k] + time_B[l] > K:\n l -= 1\n ans = max(ans,k+l)\n\nprint(ans)', 'N,M,K = map(int,input().split(" "))\nA = list(map(int,input().split(" ")))\nB = list(map(int,input().split(" ")))\n\ntime_A = [0]*(N+1)\ntime_B = [0]*(M+1)\n\nfor i in range(N):\n time_A[i+1] = time_A[i] + A[i]\nfor j in range(M):\n time_B[j+1] = time_B[j] + B[j]\n\nans = 0\nl = M\n\nfor k in range(N+1):\n if time_A[k] > K:\n break\n while time_A[k] + time_B[l] > K:\n l -= 1\n ans = max(ans,k+l)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s626642159', 's799895310']
[50960.0, 47684.0]
[315.0, 296.0]
[443, 419]
p02623
u798260206
2,000
1,048,576
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.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s468045616', 's205660272']
[47308.0, 47464.0]
[246.0, 287.0]
[342, 344]
p02623
u799215419
2,000
1,048,576
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.
['from bisect import bisect\nfrom collections import deque\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nfor i in range(1, len(A)+1):\n A[i] += A[i-1]\nfor i in range(1, len(B)+1):\n B[i] += B[i-1]\n\nindexB = len(B) - 1\nresults = [0]\nfor i in range(len(A)):\n time = A[i]\n if time > K:\n break\n enable_for_b = K - time\n results.append(i + bisect(B, enable_for_b))\n\nprint(max(results))', 'from collections import deque\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nfor i in range(1, len(A)):\n A[i] += A[i-1]\nfor i in range(1, len(B)):\n B[i] += B[i-1]\n\nindexB = len(B)\nbest = 0\nfor i in range(len(A)):\n time = A[i]\n if time > K:\n break\n while(indexB >= 0 and time + B[indexB] > K):\n indexB -= 1\n count = i+1 + indexB+1\n if (best < count):\n best = count\nprint(best)', 'from bisect import bisect\nfrom collections import deque\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA = [0]\nfor i in range(1, len(A)):\n A[i] += A[i-1]\nfor i in range(1, len(B)):\n B[i] += B[i-1]\n\nindexB = len(B) - 1\nresults = [0]\nfor i in range(len(A)):\n time = A[i]\n if time > K:\n break\n enable_for_b = K - time\n results.append(i + bisect(B, enable_for_b))\n\nprint(max(results))', 'from bisect import bisect\nfrom collections import deque\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nfor i in range(1, len(A)):\n A[i] += A[i-1]\nfor i in range(1, len(B)):\n B[i] += B[i-1]\nA.insert(0, 0)\nindexB = len(B) - 1\nresults = [0]\nfor i in range(len(A)):\n time = A[i]\n if time > K:\n break\n enable_for_b = K - time\n results.append(i + bisect(B, enable_for_b))\n\nprint(max(results))']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s701651697', 's748880969', 's763628418', 's760595739']
[40704.0, 40584.0, 40732.0, 40612.0]
[142.0, 179.0, 135.0, 314.0]
[464, 480, 468, 474]