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 | u033566567 | 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. | ["# f = open('test.txt')\nf = open('b11.txt')\nn, m, k = map(int, f.readline().split())\na = list(map(int, f.readline().split()))\nb = list(map(int, f.readline().split()))\n\na_sum = [0]\nb_sum = [0]\ncnt = 0\nbest_b = m\nconfirm = ()\n\nfor i in a:\n a_sum.append(i + a_sum[-1])\n\nfor i in b:\n b_sum.append(i + b_sum[-1])\n\nfor a_idx in range(n + 1):\n if a_sum[a_idx] > k:\n break\n for b_idx in reversed(range(best_b + 1)):\n if b_sum[b_idx] + a_sum[a_idx] <= k:\n # if cnt < a_idx + b_idx:\n cnt = max(cnt, a_idx + b_idx)\n best_b = b_idx\n break\n\nprint(cnt)\n", '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]\ncnt = 0\nbest_b = m\nconfirm = ()\n\nfor i in a:\n a_sum.append(i + a_sum[-1])\n\nfor i in b:\n b_sum.append(i + b_sum[-1])\n\nfor a_idx in range(n + 1):\n if a_sum[a_idx] > k:\n break\n for b_idx in reversed(range(best_b + 1)):\n if b_sum[b_idx] + a_sum[a_idx] <= k:\n # if cnt < a_idx + b_idx:\n cnt = max(cnt, a_idx + b_idx)\n best_b = b_idx\n break\n\nprint(cnt)\n'] | ['Runtime Error', 'Accepted'] | ['s627350326', 's110547119'] | [9176.0, 47644.0] | [26.0, 353.0] | [608, 550] |
p02623 | u035445296 | 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, b_sum = [0], [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])\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)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na_sum, b_sum = [0], [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])\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)'] | ['Time Limit Exceeded', 'Accepted'] | ['s824258922', 's570880766'] | [47652.0, 47476.0] | [2207.0, 285.0] | [371, 371] |
p02623 | u050584166 | 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\nprint(A)\nprint(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, 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'] | ['s151367400', 's831324927'] | [54484.0, 47484.0] | [326.0, 301.0] | [382, 363] |
p02623 | u052244548 | 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 functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\n\ndef main_sum():\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_len = len(A)\n maxB = len(B)\n\n Asum = [0] * (200000 + 1)\n Bsum = [0] * (200000 + 1)\n\n maxA = 0\n\n add = 0\n for i in range(1,A_len+1):\n add += A[i-1]\n Asum[i] = add\n if add <= K:\n maxA = i + 1\n else:\n break\n\n ans = maxA\n prevmax = 0\n for i in reversed(range(maxA)):\n for j in range(prevmax,maxB):\n if Bsum[j+1] == 0:\n Bsum[j+1] = (Bsum[j] + B[j])\n if Asum[i] + Bsum[j] <= K:\n if ans < i + (j + 1):\n ans = i + (j + 1)\n prevmax = j\n\n if j == maxB - 1:\n print(ans)\n exit()\n else:\n break\n\n\n print(ans)\n\nmain_sum()\n', 'import itertools\nimport functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\n\ndef main_sum():\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_len = len(A)\n maxB = len(B)\n\n Asum = [0] * (200000 + 1)\n\n maxA = 0\n\n add = 0\n for i in range(1,A_len+1):\n add += A[i-1]\n Asum[i] = add\n if add <= K:\n maxA = i + 1\n else:\n break\n\n ans = maxA\n prevmax = 0\n Bsum = 0\n for i in reversed(range(maxA)):\n for j in range(prevmax,maxB):\n Bsum += B[j]\n if Asum[i] + Bsum <= K:\n if ans < i + (j + 1):\n ans = i + (j + 1)\n prevmax = j\n\n if j == maxB - 1\n print(ans)\n exit()\n else:\n break\n\n\n print(ans)\n\nmain_sum()\n', 'import itertools\nimport functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\n\ndef main_sum():\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_len = len(A)\n B_len = len(B)\n\n Asum = [0] * (A_len + 1)\n Bsum = [0] * (B_len + 1)\n\n maxA = len(A) + 1\n maxB = len(B) + 1\n\n add = 0\n for i in range(1,A_len+1):\n Asum[i] = A[i-1] + Asum[i-1]\n\n add = 0\n for i in range(1,B_len+1):\n Bsum[i] = B[i-1] + Bsum[i-1]\n\n ans = 0\n prev = 0\n for i in reversed(range(maxA)):\n for j in range(prev,maxB):\n if Asum[i] + Bsum[j] <= K:\n prev = j\n if ans < i + j:\n ans = i + j\n if j == (maxB - 1):\n print(ans)\n exit()\n else:\n break\n\n print(ans)\n\n\n\n\nmain_sum()\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s475066863', 's541444060', 's330230800'] | [42064.0, 9092.0, 48400.0] | [2206.0, 23.0, 285.0] | [1025, 953, 950] |
p02623 | u052248839 | 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):\n a.append(a[i] + A[i])\nfor i in range(M): \n b.append(b[i] + B[i])\nprint(a)\nprint(b)\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()))\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)'] | ['Wrong Answer', 'Accepted'] | ['s371743773', 's921675668'] | [54444.0, 47472.0] | [319.0, 294.0] | [379, 361] |
p02623 | u052833850 | 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()))\ni=0\nj=0\ncount=0\nans=0\nfor i in range(1,n):\n A[i]=A[i]+A[i-1]\n\n\nfor j in range(1,m):\n B[i]=B[i]+B[i-1]\n\na_cnt=0\nb_cnt=m\nfor a_cnt in range(n+1):\n if A[a_cnt]>k:\n continue\n #print('A',A[a_cnt])\n while A[a_cnt]+B[b_cnt]>k:\n #print('B',B[b_cnt+1])\n b_cnt-=1 \n ans=max(ans,a_cnt+b_cnt)\nprint(ans)", "n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nM=0\ncount=0\nwhile M<k:\n if len(A)==0:\n M+=B.pop(0)\n if M>k:\n break\n print(M,'B')\n count+=1\n continue\n if len(B)==0:\n M+=A.pop(0)\n if M>k:\n break\n print(M,'A')\n count+=1\n continue\n if min(A[0],B[0])==A[0]:\n M+=A.pop(0)\n if M>k:\n break\n print(M,'A')\n count+=1\n else:\n M+=B.pop(0)\n if M>k:\n break\n print(M,'B')\n count+=1\nprint(count)", 'n,m,k=map(int,input().split())\nA=[0]+list(map(int,input().split()))\nB=[0]+list(map(int,input().split()))\ni=0\nj=0\ncount=0\nans=0\nfor i in range(1,n+1):\n A[i]=A[i]+A[i-1]\n\n\nfor j in range(1,m+1):\n B[i]=B[i]+B[i-1]\n\na_cnt=0\nb_cnt=m\nfor a_cnt in range(n+1):\n if A[a_cnt]>k:\n continue\n while A[a_cnt]+B[b_cnt]>k:\n b_cnt-=1 \n ans=max(ans,a_cnt+b_cnt)\nprint(ans)', 'n,m,k=map(int,input().split())\nA=[0]+list(map(int,input().split()))\nB=[0]+list(map(int,input().split()))\n\nans=0\nfor i in range(1,n+1):\n A[i]+=A[i-1]\n\n\nfor j in range(1,m+1):\n B[j]+=B[j-1]\n\n\nb_cnt=m\nfor a_cnt in range(n+1):\n if A[a_cnt]>k:\n continue\n while A[a_cnt]+B[b_cnt]>k:\n b_cnt-=1 \n\n ans=max(ans,a_cnt+b_cnt)\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s027260541', 's730402683', 's735894913', 's683159295'] | [40016.0, 42296.0, 39928.0, 39868.0] | [300.0, 2206.0, 288.0, 303.0] | [411, 513, 365, 336] |
p02623 | u054556734 | 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 scipy.sparse as sps\nimport scipy.misc as spm\nimport collections as col\nimport functools as func\nimport itertools as ite\nimport fractions as frac\nimport math as ma\nfrom math import cos,sin,tan,sqrt\nimport cmath as cma\nimport copy as cp\nimport sys\nimport re\nimport bisect as bs\nsys.setrecursionlimit(10**7)\nEPS = sys.float_info.epsilon\nPI = np.pi; EXP = np.e; INF = np.inf\nMOD = 10**9 + 7\n\ndef sinput(): return sys.stdin.readline().strip()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(n=0):\n if n: return [0 for _ in range(n)]\n else: return list(imap())\ndef farr(): return list(fmap())\ndef sarr(n=0):\n if n: return ["" for _ in range(n)]\n else: return sinput().split()\ndef adj(n): return [[] for _ in range(n)]\n\ndef meguru(ok, ng):\n while abs(ok - ng) > 1:\n mid = (ok + ng)//2\n if isOK(mid): ok = mid\n else: ng = mid\n return ok\n\ndef isOK(num): return bcum[num] <= tb\n\nn,m,k = imap()\na,b = iarr(),iarr()\nacum,bcum = np.array(a).cumsum(),np.array(b).cumsum()\n\nanss = []\nfor i in range(n+1):\n ans = i + 1\n ta = 0 if i==n+1 else acum[i]\n if ta > k: continue\n else: tb = k - ta\n #ok,ng = -1,m\n \n ans += bs.bisect_right(bcum, tb)\n anss.append(ans)\nans = max(anss) if anss else 0\nprint(ans)\n', 'import numpy as np\nimport scipy.sparse as sps\nimport scipy.misc as spm\nimport collections as col\nimport functools as func\nimport itertools as ite\nimport fractions as frac\nimport math as ma\nfrom math import cos,sin,tan,sqrt\nimport cmath as cma\nimport copy as cp\nimport sys\nimport re\nimport bisect as bs\nsys.setrecursionlimit(10**7)\nEPS = sys.float_info.epsilon\nPI = np.pi; EXP = np.e; INF = np.inf\nMOD = 10**9 + 7\n\ndef sinput(): return sys.stdin.readline().strip()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(n=0):\n if n: return [0 for _ in range(n)]\n else: return list(imap())\ndef farr(): return list(fmap())\ndef sarr(n=0):\n if n: return ["" for _ in range(n)]\n else: return sinput().split()\ndef adj(n): return [[] for _ in range(n)]\n\ndef meguru(ok, ng):\n while abs(ok - ng) > 1:\n mid = (ok + ng)//2\n if isOK(mid): ok = mid\n else: ng = mid\n return ok\n\ndef isOK(num): return bcum[num] <= tb\n\nn,m,k = imap()\na,b = iarr(),iarr()\nacum,bcum = np.array(a).cumsum(),np.array(b).cumsum()\n\nanss = []\nfor i in range(n+1):\n ans = 0 if i==n else i + 1\n ta = 0 if i==n else acum[i]\n if ta > k: continue\n else: tb = k - ta\n ok,ng = -1,m\n ans += meguru(ok,ng) + 1 \n \n anss.append(ans)\nans = max(anss) if anss else 0\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s941349340', 's453620998'] | [68276.0, 69912.0] | [819.0, 1645.0] | [1425, 1437] |
p02623 | u060582659 | 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\nA_max = 0\nB_sum = 0\nB_max = 0\nbest_num = 0\nA_max = N\nflag = True \n\n\nfor i in range(N):\n A_sum += A[i]\n if A_sum > K:\n A_sum -= A[i]\n A_max = i\n flag = False\n break\nA = A[0:A_max]\nnow_num = A_max \nmixsum = A_sum \nb_num = 0 \nif flag:\n now_num += M\n b_num = M\n for i in range(M):\n mixsum += B[i]\n if mixsum > K:\n mixsum -= B[i]\n now_num += i\n b_num = i \n break\nA.reverse()\nbest_num = now_num\nfor i in range(A_max):\n mixsum -= A[i]\n now_num -= 1\n for j in range(b_num, M):\n mixsum += B[j]\n now_num += 1\n if mixsum > K:\n mixsum -= B[j]\n now_num -= 1\n break\n if now_num > best_num:\n best_num = now_num\nprint(best_num)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\nA_max = 0\nB_sum = 0\nB_max = 0\nbest_num = 0\n\nflag = True \n\n\nA_max = N\nA_sum = 0\nfor i in range(N):\n A_sum += A[i]\n if A_sum > K:\n A_sum -= A[i]\n A_max = i\n flag = False\n break\nA = A[0:A_max]\nnow_num = A_max \nmixsum = A_sum \nb_num = 0 \nif flag:\n now_num += M\n b_num = M\n for i in range(M):\n mixsum += B[i]\n if mixsum > K:\n mixsum -= B[i]\n now_num = A_max + i\n b_num = i \n break\nA.reverse()\nbest_num = now_num\nfor i in range(A_max):\n mixsum -= A[i]\n now_num -= 1\n for j in range(b_num, M):\n mixsum += B[j]\n now_num += 1\n if mixsum > K:\n mixsum -= B[j]\n now_num -= 1\n b_num = j\n break\n if now_num > best_num:\n best_num = now_num\nprint(best_num)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA_sum = 0\nA_max = 0\nB_sum = 0\nB_max = 0\nbest_num = 0\nA_max = N\nflag = True \n\n\nfor i in range(N):\n A_sum += A[i]\n if A_sum > K:\n A_sum -= A[i]\n A_max = i\n flag = False\n break\nA = A[0:A_max]\nnow_num = A_max \nmixsum = A_sum \nb_num = 0 \nif flag:\n now_num += M\n b_num = M\n for i in range(M):\n mixsum += B[i]\n if mixsum > K:\n mixsum -= B[i]\n now_num = A_max + i\n b_num = i \n break\nA.reverse()\nbest_num = now_num\nfor i in range(A_max):\n mixsum -= A[i]\n now_num -= 1\n for j in range(b_num, M):\n mixsum += B[j]\n now_num += 1\n if mixsum > K:\n mixsum -= B[j]\n now_num -= 1\n break\n if now_num > best_num:\n best_num = now_num\nprint(best_num)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\nA_max = 0\nB_sum = 0\nB_max = 0\nbest_num = 0\n\nflag = True \n\n\nA_max = N\nA_sum = 0\nfor i in range(N):\n A_sum += A[i]\n if A_sum > K:\n A_sum -= A[i]\n A_max = i\n break\nA = A[0:A_max]\nnow_num = A_max \nmixsum = A_sum \nb_num = 0 \nif flag:\n now_num += M\n b_num = M\n for i in range(M):\n mixsum += B[i]\n if mixsum > K:\n mixsum -= B[i]\n now_num = A_max + i\n b_num = i \n break\nA.reverse()\nbest_num = now_num\nfor i in range(A_max):\n mixsum -= A[i]\n now_num -= 1\n for j in range(b_num, M):\n mixsum += B[j]\n now_num += 1\n if mixsum > K:\n mixsum -= B[j]\n now_num -= 1\n b_num = j #miss\n break\n if now_num > best_num:\n best_num = now_num\nprint(best_num)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s354173876', 's821280148', 's834700299', 's749610831'] | [41120.0, 40876.0, 40976.0, 40932.0] | [436.0, 355.0, 410.0, 343.0] | [1114, 1145, 1121, 1130] |
p02623 | u060752882 | 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 = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nAA = [0]\nBB = [0]\nr = 0\nfor i in A:\n r += i\n AA.append(r)\nr = 0\nfor i in B:\n r += i\n BB.append(r)\nans = 0\na = N\nb = 0\nwhile AA[a]+BB[b] > K:\n a -= 1\nans = a+b\n\nwhile a > 0:\n while b < M:\n if AA[a]+BB[b+1] <= K:\n b += 1\n else:\n break\n print(a,b,AA[a]+BB[b])\n if ans < a+b:\n ans = a+b\n if b == M:\n break\n a -= 1\nprint(ans)\n', 'N,M,K = map(int,input().split())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nAA = [0]\nBB = [0]\nr = 0\nfor i in A:\n r += i\n AA.append(r)\nr = 0\nfor i in B:\n r += i\n BB.append(r)\nans = 0\na = N\nb = 0\nwhile AA[a]+BB[b] > K:\n a -= 1\nans = a+b\n\nwhile a >= 0:\n while b < M:\n if AA[a]+BB[b+1] <= K:\n b += 1\n else:\n break\n print(a,b,AA[a]+BB[b])\n if ans < a+b:\n ans = a+b\n if b == M:\n break\n a -= 1\nprint(ans)\n\n', 'N,M,K = map(int,input().split())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nAA = [0]\nBB = [0]\nr = 0\nfor i in A:\n r += i\n AA.append(r)\nr = 0\nfor i in B:\n r += i\n BB.append(r)\nans = 0\na = N\nb = 0\nwhile AA[a]+BB[b] > K:\n a -= 1\nans = a+b\n\nwhile a >= 0:\n while b < M:\n if AA[a]+BB[b+1] <= K:\n b += 1\n else:\n break\n if ans < a+b:\n ans = a+b\n if b == M:\n break\n a -= 1\nprint(ans)\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s116398795', 's283592561', 's452650783'] | [47380.0, 47644.0, 46768.0] | [477.0, 480.0, 311.0] | [510, 512, 485] |
p02623 | u060793972 | 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()))\nea=[0]\nfor i in range(n):\n ea.append(ea[i]+a[i])\neb=[0]\nfor i in range(m):\n eb.append(eb[i]+b[i])\ntb=m\np=0\nif n<m:\n ea,eb=eb,ea\n n,m=m,n\nfor i in range(n+1):\n while ea[i]+eb[tb]>k:\n if tb==0:\n break\n tb-=1\n if ea[i]+eb[tb]<=k:\n p=max(i+tb,p)\nprint(p)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nea=[0]\nfor i in range(n):\n ea.append(ea[i]+a[i])\neb=[0]\nfor i in range(m):\n eb.append(eb[i]+b[i])\nif n<m:\n ea,eb=eb,ea\n n,m=m,n\ntb=m\np=0\nfor i in range(n+1):\n while ea[i]+eb[tb]>k:\n if tb==0:\n break\n tb-=1\n if ea[i]+eb[tb]<=k:\n p=max(i+tb,p)\nprint(p)'] | ['Runtime Error', 'Accepted'] | ['s761830390', 's991675480'] | [47496.0, 47348.0] | [297.0, 331.0] | [397, 397] |
p02623 | u068844030 | 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_right\n\nn, m, k = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\n\n\na_cum = list(accumulate(a))\nb_cum = list(accumulate(b))\n\nans = [0]\nfor i in range(n+1): \n c = bisect_right(b, k-a[i]) - 1 \n if c != -1: \n ans.append(c+i)\nprint(max(ans))', 'from itertools import accumulate\nfrom bisect import bisect_right\n\nn, m, k = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\n\n\na_cum = list(accumulate(a))\nb_cum = list(accumulate(b))\n\nans=[0]\nfor i in range(n+1): #0~n+1\n c = bisect_right(b,k-a[i])-1 \n \n if c!=-1: \n ans.append(c+i)\nprint(max(ans))', 'from itertools import accumulate\nfrom bisect import bisect_right\n\nn, m, k = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\n\n\na_cum = [0] + list(accumulate(a))\nb_cum = [0] + list(accumulate(b))\n\nans = [0]\nfor i in range(n + 1): #0~n+1\n c = bisect_right(b_cum, k-a_cum[i]) - 1 \n \n if c != -1: \n ans.append(c+i)\n\nprint(max(ans))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s460359866', 's659158583', 's177636701'] | [50732.0, 49368.0, 52004.0] | [250.0, 251.0, 269.0] | [403, 712, 742] |
p02623 | u072717685 | 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\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n a = np.array(readline().split(), np.int64)\n b = np.array(readline().split(), np.int64)\n aa = a.cumsum()\n ba = b.cumsum()\n r = np.searchsorted(ba, k)\n aaa = k - aa\n for i1, aaae in enumerate(aaa):\n if aaae > 0:\n r = max(r, np.searchsorted(ba, aaae) + i1 + 2)\n print(r)\n\nif __name__ == '__main__':\n main()", "import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n a = np.array(readline().split(), np.int64)\n b = np.array(readline().split(), np.int64)\n aa = a.cumsum()\n ba = b.cumsum()\n aa = aa[aa <= k]\n ba = ba[ba <= k]\n r = np.searchsorted(ba, k, side='right')\n rs = np.searchsorted(ba, k - aa, side='right')\n rs += np.arange(1, len(ba))\n r = max(r, rs.max())\n print(r)\n\nif __name__ == '__main__':\n main()\n", "import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n a = np.array(readline().split(), np.int64)\n b = np.array(readline().split(), np.int64)\n aa = np.zeros(n + 1, np.int64)\n ba = np.zeros(m + 1, np.int64)\n aa[1:] = a.cumsum()\n ba[1:] = b.cumsum()\n aa = aa[aa <= k]\n ba = ba[ba <= k]\n rs = np.searchsorted(ba, k - aa, side='right') - 1\n rs += np.arange(len(aa))\n r = rs.max()\n print(r)\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s803728163', 's876547981', 's994918214'] | [56188.0, 56300.0, 56192.0] | [759.0, 210.0, 219.0] | [515, 547, 572] |
p02623 | u075304271 | 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 collections\nimport fractions\nimport itertools\nimport functools\nimport operator\nimport bisect\n\ndef solve():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n ruia, ruib = [0], [0]\n for i in range(n): ruia.append(a[i]+ruia[i])\n for i in range(m): ruib.append(b[i]+ruib[i])\n ans = 0\n j = m\n for i in range(n+1):\n if ruia[i] > k:\n break\n while(k > ruia[i]+ruib[j]):\n j -= 1\n ans = max(ans, i+j)\n print(ans)\n return 0\n\nif __name__ == "__main__":\n solve()', 'import math\nimport collections\nimport fractions\nimport itertools\nimport functools\nimport operator\nimport bisect\n\ndef solve():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n ruia, ruib = [0], [0]\n for i in range(n): ruia.append(a[i]+ruia[i])\n for i in range(m): ruib.append(b[i]+ruib[i])\n ans = 0\n j = m\n for i in range(n+1):\n if ruia[i] > k:\n break\n while(k > ruia[i]+ruib[j]):\n j -= 1\n ans = max(ans, i+j)\n print(ans)\n return 0\n\nif __name__ == "__main__":\n solve()', 'import math\nimport collections\nimport fractions\nimport itertools\nimport functools\nimport operator\nimport bisect\n\ndef solve():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n ruia, ruib = [0], [0]\n for i in range(n): ruia.append(a[i]+ruia[i])\n for i in range(m): ruib.append(b[i]+ruib[i])\n ans = 0\n j = m\n for i in range(n+1):\n if ruia[i] > k:\n break\n while(ruib[j]>k-ruia[i]):\n j -= 1\n ans = max(ans, i+j)\n print(ans)\n return 0\n\nif __name__ == "__main__":\n solve()'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s479526922', 's835574912', 's377283566'] | [48860.0, 48836.0, 48872.0] | [199.0, 252.0, 224.0] | [609, 613, 607] |
p02623 | u075364767 | 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\n\n\n\nN,M,K=map(int,input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\n\n\n\n\n\nA_wa = [0]\nfor i in range(N) :\n A_wa.append(A_wa[i]+A[i])\n\nB_wa = [0]\nfor i in range(M) :\n B_wa.append(B_wa[i]+B[i])\n\n\n\n\nans = 0\nend = N \n\nfor i in range(M+1):\n A_use = K-B_wa[i]\n if A_use<0: \n break\n \n \n A_MAX = 0\n start = 0\n while end-start>=1 : \n now = int((start + end+1)/2) \n if A_wa[now]==A_use : \n A_MAX = now \n break\n elif A_wa[now]<A_use : \n start = now \n A_MAX = now \n else : \n end = now-1\n \n \n \n if A_MAX+i>ans :\n ans=A_MAX+i\n\n end=A_MAX\u3000\n\n\nprint(ans)\n \n\n \n\n\n\n\n', '\n\n\n\n\nN,M,K=map(int,input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\n\n\n\n\n\nA_wa = [0]\nfor i in range(N) :\n A_wa.append(A_wa[i]+A[i])\n\nB_wa = [0]\nfor i in range(M) :\n B_wa.append(B_wa[i]+B[i])\n\n\n\n\nans = 0\nend = N \n\n\n\nfor i in range(M+1):\n A_use = K-B_wa[i]\n if A_use<0: \n break\n \n \n \n A_MAX = 0\n start = 0\n while end-start>=1 : \n now = int((start + end + 1)/2)\n if A_wa[now]==A_use : \n A_MAX = now \n break\n elif A_wa[now]<A_use : \n start = now \n A_MAX = now \n else : \n end = now-1\n \n end=A_MAX \n \n \n \n if A_MAX+i>ans :\n ans=A_MAX+i\n\n\n\nprint(ans)\n \n\n \n\n\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s305320503', 's449328897'] | [8916.0, 47244.0] | [28.0, 1752.0] | [1303, 1228] |
p02623 | u077291787 | 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. | ['# D - Sum of Divisors\nfrom numba import njit\n\n\n@njit\ndef solve(N):\n res = 0\n for a in range(1, N + 1):\n for b in range(1, N // a + 1):\n res += a * b\n return res\n\n\ndef main():\n N = int(input())\n print(solve(N))\n\n\nif __name__ == "__main__":\n main()\n', 'from bisect import*;from itertools import*;n,_,k,*x=map(int,open(0).read().split());c=accumulate;*b,=c(x[n:]);print(max(i+bisect(b,k-v)for i,v in enumerate(c([0]+x[:n]))if v<=k))'] | ['Runtime Error', 'Accepted'] | ['s856584170', 's797438621'] | [91928.0, 55268.0] | [369.0, 222.0] | [283, 178] |
p02623 | u085772923 | 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()))\nA.insert(0, 0)\nB = list(map(int,input().split()))\na = []\nb = []\n\ndef nibun(L,l,r,target):\n\n wrk = -(-(l+r)//2)\n \n# print(l,r,target,wrk)\n \n if r == l:\n if r == len(L):\n return 0\n else:\n return wrk + 1\n \n if l == (len(L)-1):\n if L[wrk-1] > target:\n return wrk\n else:\n return 0\n\n if L[wrk] == target:\n return wrk+1\n\n elif L[wrk] > target:\n return nibun(L,l,wrk-1,target)\n\n else:\n return nibun(L,wrk,r,target)\n\n \ns = 0\nfor i,e in enumerate(B):\n s += e \n b.append(s)\n\ns = 0\nans = 0\nfor i in range(len(A)):\n\n# print(s,i,A[i])\n s += A[i]\n if s > K:\n break\n else: \n wrk = nibun(b,-1,len(b),K-s)\n \n ans=max(ans,i+1+wrk)\n\n\nprint(ans)', 'N, M, K = map(int,input().split())\n\nA = list(map(int,input().split()))\nA.insert(0, 0)\nB = list(map(int,input().split()))\na = []\nb = []\n\ndef nibun(L,l,r,target):\n\n wrk = -(-(l+r)//2)\n \n# print(l,r,target,wrk)\n \n if r == l:\n if r == len(L):\n return 0\n else:\n return wrk + 1\n \n if l == (len(L)-1):\n if L[wrk-1] > target:\n return wrk\n else:\n return 0\n\n if L[wrk] == target:\n return wrk+1\n\n elif L[wrk] > target:\n return nibun(L,l,wrk-1,target)\n\n else:\n return nibun(L,wrk,r,target)\n\n \ns = 0\nfor i,e in enumerate(B):\n s += e \n b.append(s)\n\ns = 0\nans = 0\nfor i in range(len(A)):\n\n# print(s,i,A[i])\n s += A[i]\n if s > K:\n break\n else: \n wrk = nibun(b,-1,len(b),K-s)\n \n ans=max(ans,i+1+wrk)\n\n\nprint(ans)', 'N, M, K = map(int,input().split())\n\nA = list(map(int,input().split()))\nA.insert(0, 0)\nB = list(map(int,input().split()))\na = []\nb = []\n\ndef nibun(L,l,r,target):\n\n wrk = -(-(l+r)//2)\n \n# print(l,r,target,wrk)\n \n if r == l:\n if r == len(L):\n return 0\n else:\n return wrk + 1\n \n if l == (len(L)-1):\n if L[wrk-1] > target:\n return wrk\n else:\n return 0\n\n if L[wrk] == target:\n return wrk+1\n\n elif L[wrk] > target:\n return nibun(L,l,wrk-1,target)\n\n else:\n return nibun(L,wrk,r,target)\n\n \ns = 0\nfor i,e in enumerate(B):\n s += e \n b.append(s)\n\ns = 0\nans = 0\nfor i in range(len(A)):\n\n# print(s,i,A[i])\n s += A[i]\n if s > K:\n break\n else: \n wrk = nibun(b,-1,len(b),K-s)\n \n ans=max(ans,i+wrk)\n\n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s395433780', 's799160822', 's899292267'] | [41084.0, 41168.0, 41020.0] | [1396.0, 1396.0, 1403.0] | [813, 813, 811] |
p02623 | u086138398 | 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.append(10**9+1)\nB.append(10**9+1)\na = 0\nb = 0\nans = 0\nt = 0\nwhile t < K :\n if A[a] < B[b]:\n if t+A[a] <= K:\n ans += 1\n t += A[a]\n a += 1\n else:\n break\n else:\n if t+B[b] <= K:\n ans += 1\n t += B[b]\n b += 1\n else:\n break\nans2 = 0\na = 0\nb = 0\nt = 0\nwhile t < K :\n if A[a] > B[b]:\n if t+A[a] <= K:\n ans2 += 1\n t += A[a]\n a += 1\n else:\n break\n else:\n if t+B[b] <= K:\n ans2 += 1\n t += B[b]\n b += 1\n else:\n break\nprint(min(ans,ans2))', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = 0\nb = 0\nans = 0\nt = sum(A)\ntemp = 0\nif t <= K:\n ans = N\nj = 0\nans2 = 0\nfor i in range(0,N+1):\n if i != 0:\n t -= A[-i]\n while t < K and j < len(B):\n if t + B[j] <= K:\n ans2 += 1\n t += B[j]\n j += 1\n else:\n break\n if t <= K:\n ans = max(ans,len(A)-i+ans2)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s593072091', 's187043481'] | [41652.0, 40444.0] | [347.0, 333.0] | [774, 454] |
p02623 | u089376182 | 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. | ['counter = 0\nans = 0\n\nfor i in range(n+1):\n if sum(A[:i])>k:\n break\n for j in range(m+1):\n if sum(A[:i])+sum(B[:j])<=k:\n ans = max(ans, i+j)\n else:\n break\n \nprint(ans)', 'import bisect\n\nn,m,k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA_cum = [0]\nB_cum = [0]\n\nfor i in range(n):\n A_cum.append(A_cum[i]+A[i])\n \nfor i in range(m):\n B_cum.append(B_cum[i]+B[i])\n \nans = 0 \nfor i, a in enumerate(A_cum):\n rest = k-a\n if rest<=0:\n continue\n ans = max(ans, bisect.bisect_left(B_cum, rest)+i)\n \nprint(ans)', 'import bisect\n\nn,m,k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA_cum = [0]\nB_cum = [0]\n\nfor i in range(n):\n A_cum.append(A_cum[i]+A[i])\n \nfor i in range(m):\n B_cum.append(B_cum[i]+B[i])\n \nans = 0 \nfor i in range(n):\n rest = k-A_cum[i]\n if rest<=0:\n continue\n ans = max(ans, bisect.bisect_left(B_cum, rest)+i)\n \nprint(ans)', 'import bisect\n\nn,m,k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA_cum = [0]\nB_cum = [0]\n\nfor i in range(n):\n A_cum.append(A_cum[i]+A[i])\n \nfor i in range(m):\n B_cum.append(B_cum[i]+B[i])\n \nans = 0 \nfor i in range(n+1):\n rest = k-A_cum[i]\n if rest<=0:\n continue\n ans = max(ans, bisect.bisect_left(B_cum, rest)+i)\n \nprint(ans)', 'import bisect\n\nn,m,k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA_cum = [0]\nB_cum = [0]\n\nfor i in range(n):\n A_cum.append(A_cum[i]+A[i])\n \nfor i in range(m):\n B_cum.append(B_cum[i]+B[i])\n\nans = 0 \nfor i in range(n+1):\n rest = k-A_cum[i]\n if rest<0:\n continue\n \n ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)\n \nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s032290122', 's400914074', 's850210006', 's890882485', 's221948114'] | [9072.0, 47272.0, 47328.0, 47320.0, 47552.0] | [28.0, 343.0, 330.0, 332.0, 318.0] | [226, 398, 394, 396, 397] |
p02623 | u091051505 | 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 = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nA = [0]\nB = [0]\nfor i in range(n):\n A.append(A[-1] + a[i])\nfor j in range(1, m):\n B.append(B[-1] + b[j])\n \nans = 0\nfor i in range(n):\n time = A[i]\n b_index = 0\n if time > k:\n break\n if k - time > 0:\n b_index = bisect_right(B, k - time)\n ans = max(ans, i + b_index - 1)\nprint(ans)', 'from collections import deque\n\nn, m, k = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\ntime = 0\nans = 0\naaa = deque(a)\nbbb = deque(b)\nwhile (time < k) & ((len(aaa) > 0) | (len(bbb) > 0)):\n if (len(aaa) > 0 | len(bbb) > 0):\n if aaa[0] <= bbb[0]:\n time += aaa.popleft()\n ans += 1\n else:\n time += bbb.popleft()\n ans += 1\n elif aaa:\n time += aaa.popleft()\n ans += 1\n elif bbb:\n time += bbb.popleft()\n ans += 1\nif time <= k:\n print(ans)\nelse:\n print(ans - 1)', 'from bisect import bisect_right\n\nn, m, k = map(int, input().split())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nA = [0]\nB = [0]\nfor i in range(n):\n A.append(A[-1] + a[i])\nfor j in range(m):\n B.append(B[-1] + 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 -= 1\n ans = max(ans, i + j)\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s503986042', 's904609483', 's900812498'] | [48464.0, 40616.0, 47500.0] | [345.0, 353.0, 298.0] | [463, 614, 404] |
p02623 | u092061507 | 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 = input().split()\n\ndesk1 = list(map(int, input().split()))\ndesk2 = list(map(int, input().split()))\n\nmax_time = int(K)\nitem1 = [0]\nitem2 = [0]\nfor i in desk1:\n item1.append(item1[-1] + i)\nfor i in desk2:\n item2.append(item2[-1] + i)\n\nret = 0\nfor i, t in enumerate(item1):\n remain_time = max_time - t\n if remain_time > 0:\n j = bisect.bisect(item2, remain_time) - 1\n if j < 0:\n j = 0\n ret = max(ret, i + j)\n else:\n ret = max(ret, i)\nprint(ret)import bisect\n\nN, M, K = input().split()\n\ndesk1 = list(map(int, input().split()))\ndesk2 = list(map(int, input().split()))\n\nmax_time = int(K)\nitem1 = [0]\nitem2 = [0]\nfor i in desk1:\n item1.append(item1[-1] + i)\nfor i in desk2:\n item2.append(item2[-1] + i)\n\nret = 0\nfor i, t in enumerate(item1):\n remain_time = max_time - t\n if remain_time > 0:\n j = bisect.bisect(item2, remain_time) - 1\n if j < 0:\n j = 0\n ret = max(ret, i + j)\n else:\n ret = max(ret, i)\nprint(ret)', 'import bisect\n\nN, M, K = input().split()\n\ndesk1 = list(map(int, input().split()))\ndesk2 = list(map(int, input().split()))\n\nmax_time = int(K)\nitem1 = [0]\nitem2 = [0]\nfor i in desk1:\n item1.append(item1[-1] + i)\nfor i in desk2:\n item2.append(item2[-1] + i)\n\nret = 0\nfor i, t in enumerate(item1):\n remain_time = max_time - t\n if remain_time >= 0:\n j = bisect.bisect(item2, remain_time) - 1\n ret = max(ret, i + j)\n\nprint(ret)'] | ['Runtime Error', 'Accepted'] | ['s900228361', 's344857300'] | [9012.0, 47520.0] | [20.0, 307.0] | [1034, 447] |
p02623 | u092387689 | 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 = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\ncnt = 0\nt = 0\nwhile(k > t):\n if(len(A)==0):\n now = B.pop(0)\n t += now\n cnt += 1\n elif(len(B)==0):\n now = A.pop(0)\n t += now\n cnt += 1\n else:\n if(A[0] > B[0]):\n now = B.pop(0)\n else:\n now = A.pop(0)\n t += now\n cnt += 1\nprint(t,k)\nif(t > k):\n cnt -= 1\nprint(cnt)', 'import bisect\n\nn,m,k = map(int,input().split())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\nA_sum = [0]*(n+1)\nB_sum = [0]*(m+1)\n\nfor i in range(n):\n A_sum[i+1] = A_sum[i] + A[i]\n\nfor i in range(m):\n B_sum[i+1] = B_sum[i] + B[i]\n\nA_limit = bisect.bisect_right(A_sum,k) - 1\nmc = 0\nB_i = 0\nfor i in range(A_limit,-1,-1):\n remain_k = k - A_sum[i]\n while((remain_k-B_sum[B_i])>=0):\n B_i += 1\n if(B_i==(m+1)):\n break\n B_i -= 1\n mc = max(mc,(i+B_i))\n\nprint(mc) '] | ['Wrong Answer', 'Accepted'] | ['s654940777', 's519644049'] | [42352.0, 48496.0] | [2206.0, 358.0] | [473, 530] |
p02623 | u094191970 | 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 sys import stdin\nnii=lambda:map(int,stdin.readline().split())\nlnii=lambda:list(map(int,stdin.readline().split()))\n\nn=int(input())\n\ndef eratosthenes(lim):\n is_p=[2]*lim\n\n is_p[0]=0\n is_p[1]=1\n\n for i in range(2,lim):\n for j in range(i*2,lim,i):\n is_p[j] += 1\n\n return is_p\n\nlim=n+1\nis_p=eratosthenes(lim)\n\nans=0\nfor i in range(1,n+1):\n ans+=i*is_p[i]\nprint(ans)', 'from sys import stdin\nnii=lambda:map(int,stdin.readline().split())\nlnii=lambda:list(map(int,stdin.readline().split()))\nfrom bisect import bisect_right\nfrom itertools import accumulate\n\nn,m,k=nii()\na=lnii()\nb=lnii()\nar=[0]+list(accumulate(a))\nbr=list(accumulate(b))\n\nans=0\nfor i in range(n+1):\n time=ar[i]\n if time>k:\n break\n t_ans=i\n inx=bisect_right(br,k-time)\n t_ans+=inx\n ans=max(ans,t_ans)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s511829967', 's143000306'] | [9144.0, 49332.0] | [29.0, 283.0] | [379, 413] |
p02623 | u100641536 | 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\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n n,m,k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n sa = np.cumsum([0]+a)\n sb = np.cumsum([0]+b)\n print (sa,sb)\n exit()\n for i in range(n):\n sa[i+1] = sa[i] + a[i]\n for i in range(m):\n sb[i+1] = sb[i] + b[i]\n rx = 0\n rb = m\n for ra in range(0,n+1): \n while (sb[rb] + sa[ra]) > k and rb>0 :\n rb-=1\n if (sb[rb] + sa[ra]) <= k:\n rx = max(rx,ra+rb)\n print(rx)\n\nif __name__ == '__main__':\n main()", 'import sys\nimport numpy as np\nfrom numba import jit, njit\ninput = lambda: sys.stdin.buffer.readline().rstrip()\n\n@njit(cache=True)\ndef main(n,m,k,a,b):\n sa = np.cumsum(a)\n sb = np.cumsum(b)\n rx = 0\n rb = m\n for ra in range(0,n+1): \n while (sb[rb] + sa[ra]) > k and rb>0 :\n rb-=1\n if (sb[rb] + sa[ra]) <= k:\n rx = max(rx,ra+rb)\n return(rx)\n\nn,m,k = map(int, input().split())\na = np.array([0]+list(map(int, input().split())))\nb = np.array([0]+list(map(int, input().split())))\nprint(main(n,m,k,a,b))'] | ['Wrong Answer', 'Accepted'] | ['s681701763', 's454716909'] | [58556.0, 118664.0] | [231.0, 738.0] | [576, 517] |
p02623 | u107269063 | 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])\nprint(a,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, 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'] | ['s983907370', 's876729033'] | [54844.0, 47336.0] | [324.0, 281.0] | [373, 364] |
p02623 | u110311725 | 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 = 0\ntime = 0\n \n \nfor i in range(len(a)):\n time += a[i]\n if time > k:\n time -=a[i]\n break\n ans += 1\n \ntmp = 0\ncount_a = ans\n \nfor j in range(len(b)):\n time += b[j]\n tmp = count_a + j + 1\n if time > k:\n while count_a > 0 & time > k:\n time -= a[count_a]\n count_a -= 1\n tmp -= 1\n if time > k:\n tmp = j\n if tmp > ans:\n ans = tmp\n break\n else:\n tmp = count_a + j + 1\n if tmp > ans:\n ans = tmp\nprint(ans)', 'n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n \nans = 0\ntime = 0\na_time = 0\ntemp = 0\nif a[0] > k:\n j = 0\n while time <= k:\n time += b[j]\n j += 1\n ans += 1\nelse:\n for i in range(n):\n a_time += a[i]\n if a_time > k:\n break\n else:\n time = a_time\n temp = i + 1\n j = 0\n while time <= k:\n time += b[j]\n j += 1\n temp +=1\n temp += j\n if temp > ans:\n ans = temp\n \nprint(ans)', 'n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nans = 0\ntime = 0\n\n\nfor i in range(len(a)):\n time += a[i]\n if time > k:\n time -=a[i]\n break\n ans += 1\n \ntmp = ans\nsub = ans\n\nfor j in range(len(b)):\n time += b[j]\n if time > k:\n if sub != 0: \n for i in range(sub):\n time -= a[sub - 1 - i]\n if time <= k:\n tmp = tmp - i\n sub = sub - i\n break\n if i == sub & time > k:\n tmp -= 1\n else:\n break\n \n tmp += 1\n if tmp > ans :\n ans = tmp\n \nprint(ans)', 'n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n \nans = 0\ntime = 0\n \n \nfor i in range(len(a)):\n time += a[i]\n if time > k:\n time -=a[i]\n break\n ans += 1\n \ncount_a = ans\n \nfor j in range(len(b)):\n time += b[j]\n if time > k:\n while count_a > 0 & time > k:\n time -= a[count_a]\n count_a -= 1\n if time > k:\n tmp = 0\n else:\n tmp = count_a + j\n if tmp > ans :\n ans = tmp\n \nprint(ans)', 'n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n \nans = 0\ntime = 0\na_time = 0\ntemp = 0\nif a[0] > k:\n j = 0\n while time <= k:\n time += b[j]\n j += 1\n ans += 1\nelse:\n for i in range(n):\n a_time += a[i]\n if a_time > k:\n break\n else:\n time = a_time\n j = 0\n while time <= k:\n time += b[j]\n j += 1\n temp = i + 1 + j \n if temp > ans:\n ans = temp\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]\nsum_b = [0]\n\nfor i in range(n):\n sum_a.append(sum_a[i] + a[i])\nfor j in range(m):\n sum_b.append(sum_b[j] + b[j])\n\ntemp = 0\nj = m\nans = 0\nfor i in range(n+1):\n if sum_a[i] > k:\n temp = i -1\n if temp > ans:\n ans = temp\n break\n else:\n while k - sum_a[i] < sum_b[j]:\n j -= 1\n temp = i + j\n if temp > ans:\n ans = temp\n \nprint(temp)', 'n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsum_a = [0]\nsum_b = [0]\n\nfor i in range(n):\n sum_a.append(sum_a[i] + a[i])\nfor j in range(m):\n sum_b.append(sum_b[j] + b[j])\n\ntemp = 0\nj = m\nans = 0\nfor i in range(n+1):\n if sum_a[i] > k:\n temp = i -1\n if temp > ans:\n ans = temp\n break\n else:\n while k - sum_a[i] < sum_b[j]:\n j -= 1\n temp = i + j\n if temp > ans:\n ans = temp\n \nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s200183497', 's481299614', 's533883038', 's573414443', 's772770331', 's840018103', 's844762493'] | [40768.0, 40620.0, 42460.0, 40484.0, 40532.0, 47404.0, 47544.0] | [197.0, 2206.0, 339.0, 205.0, 2206.0, 262.0, 264.0] | [683, 627, 704, 544, 596, 543, 542] |
p02623 | u113028239 | 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 main():\n n, m, k = map(int, input().split())\n a = [int(x) for x in input().split()]\n b = [int(x) for x in input().split()]\n\n a_sum = [0 for x in range(n)]\n b_sum = [0 for x in range(m)]\n\n a_sum[0] = a[0]\n b_sum[0] = b[0]\n\n max_counter = 0\n\n for i in range(1, n):\n a_sum[i] = a[i] + a_sum[i - 1]\n\n for i in range(1, n):\n b_sum[i] = b[i] + b_sum[i - 1]\n\n for i in range(n):\n for j in range(m):\n if k >= a_sum[i] + b_sum[j] and max_counter < i + j + 2:\n max_counter = i + j + 2\n \n print(max_counter)\n\nif __name__ == '__main__':\n main()", "def main():\n n, m, k = map(int, input().split())\n a = [int(x) for x in input().split()]\n b = [int(x) for x in input().split()]\n\n a_sum = [0 for x in range(n)]\n b_sum = [0 for x in range(m)]\n\n a_sum[0] = a[0]\n b_sum[0] = b[0]\n\n max_counter = 0\n\n for i in range(1, n):\n a_sum[i] = a[i] + a_sum[i - 1]\n\n for i in range(1, m):\n b_sum[i] = b[i] + b_sum[i - 1]\n\n\n print(a_sum)\n print(b_sum)\n\n for i in range(n):\n if a_sum[i] > k:\n break\n\n for j in range(m - 1, -1, -1):\n if k >= a_sum[i] + b_sum[j] and max_counter < i + j + 2:\n max_counter = i + j + 2\n break\n \n print(max_counter)\n\nif __name__ == '__main__':\n main()", "def main():\n n, m, k = map(int, input().split())\n a = [int(x) for x in input().split()]\n b = [int(x) for x in input().split()]\n\n a_sum = [0]\n b_sum = [0] \n\n max_counter = 0\n\n j = m\n\n for i in range(n):\n a_sum.append(a_sum[i] + a[i])\n\n for i in range(m):\n b_sum.append(b_sum[i] + b[i])\n\n for i in range(n + 1):\n if a_sum[i] > k:\n break\n\n while k < a_sum[i] + b_sum[j]:\n j -= 1\n \n max_counter = max(max_counter, i + j)\n\n print(max_counter)\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s162462209', 's793284868', 's452763741'] | [47784.0, 54792.0, 47480.0] | [2207.0, 2212.0, 228.0] | [629, 743, 573] |
p02623 | u113107956 | 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):\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) \n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ncnt_a=0\ncnt_b=0\nans=0\nnum_a=0\nnum_b=0\nfor i in range(n):\n num_a+=i\n if num_a>k:\n num_a=i\n if i==n-1:\n num_a=n\nfor i in range(m):\n num_b+=i\n if num_b>k:\n num_b=i\n if i ==n-1:\n num_b=n\nnum=max(num_a,num_b)\nfor i in range(200000):\n if cnt_a<n and cnt_b<m:\n if a[cnt_a]<=b[cnt_b]:\n k-=a[cnt_a]\n if k<0:\n break\n ans+=1\n cnt_a+=1\n else:\n k-=b[cnt_b]\n if k<0:\n break\n ans+=1\n cnt_b+=1\n elif cnt_a<n and cnt_b>=m:\n k-=a[cnt_a]\n if k<0:\n break\n ans+=1\n cnt_a+=1\n elif cnt_a>=n and cnt_b<m:\n k-=b[cnt_b]\n if k<0:\n break\n ans+=1\n cnt_b+=1\n else:\n break\nprint(max(num,ans))\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]\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) \n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s114935489', 's234522060', 's167409663'] | [47476.0, 40676.0, 47472.0] | [192.0, 273.0, 284.0] | [331, 948, 331] |
p02623 | u113255362 | 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, K=map(int,input().split())\nList_A = list(map(int, input().split()))\nList_B = list(map(int, input().split()))\nSumListA=[]\nSumListA.append(List_A[0])\nres =0\na=0\nfor i in range(1,A):\n a = SumListA[i-1]+List_A[i]\n if a < K:\n SumListA.append(a)\n else:\n break\nSumListB=[]\nSumListB.append(List_B[0])\nfor i in range(1,B):\n a = SumListB[i-1]+List_B[i]\n if a < K:\n SumListB.append(a)\n else:\n break\nprint(SumListA,SumListB)\nfor i in range(len(SumListA)):\n for j in range(len(SumListB)):\n a = SumListA[i]+SumListB[j] \n if a <= K:\n if i+j+2>res:\n res = i+j+2\n\nprint(res)', 'A,B,K=map(int,input().split())\nList_A = list(map(int, input().split()))\nList_B = list(map(int, input().split()))\nSumListA=[]\nSumListA.append(0)\nSumListB=[]\nSumListB.append(0)\nres =0\na=0\nfor i in range(A):\n SumListA.append(SumListA[i]+List_A[i])\nfor i in range(B):\n SumListB.append(SumListB[i]+List_B[i])\n\nj=B\nfor i in range(A+1):\n if SumListA[i] > K:\n break\n while K-SumListA[i] < SumListB[j]:\n j += -1\n res = max(i+j,res)\nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s857797816', 's613038546'] | [46244.0, 47540.0] | [2212.0, 299.0] | [599, 444] |
p02623 | u114099505 | 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\n\n\n\n\nn, m, k = map(int, input().split())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\n\nacum1 = [0]\nfor i in range(n):\n acum1.append( arr1[-1] + arr1[i] )\n\nacum2 = [0]\nfor i in range(m):\n acum2.append( arr2[-1] + arr2[i])\n\nans = 0\nj = m\nfor i in range(n+1): \n if acum1[i] < k:\n break\n while acum2[j] > k - acum1[i] and j>0: \n\n j -= 1\n ans = max(0,i+j)\n\nprint(ans)', 'n,m,k = map(int, input().split())\narr1 = list(map(int,input().split()))\narr2 = list(map(int,input().split()))\n\nacum1 = [0]\nfor i in range(n):\n acum1.append(acum1[-1]+arr1[i])\n\nacum2 = [0]\nfor i in range(m):\n acum2.append(acum2[-1]+arr2[i])\n\nans = 0\nj = m\nfor i in range(n+1):\n if acum1[i]>k:\n break\n while acum2[j] < k - acum1[i] and j > 0:\n ans = max(ans, i+j)\n j -= 1\n\nprint(ans)', '\n\n\n\n\n\nn, m, k = map(int, input().split())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\n\nacum1 = [0]\nfor i in range(n):\n acum1.append( arr1[-1] + arr1[i] )\n\nacum2 = [0]\nfor i in range(m):\n acum2.append( arr2[-1] + arr2[i])\n\nans = 0\nj = m\nfor i in range(n+1): \n if acum1[i] < k:\n break\n while acum2[j] > k - acum1[i] and j>0: \n\n j -= 1\n ans = max(ans,i+j)\n\nprint(ans)', '\n\n\n\n\n\nn, m, k = map(int, input().split())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\n\nacum1 = [0]\nfor i in range(n):\n acum1.append( arr1[-1] + arr1[i] )\n\nacum2 = [0]\nfor i in range(m):\n acum2.append( arr2[-1] + arr2[i])\n\nans = 0\nj = m\nfor i in range(n):\n if acum1[i] < k:\n break\n for j in range(m):\n if acum1[i] + acum2[j] > k:\n j -= 1\n ans = max(0,i+j)\n\nprint(ans)', 'from collections import deque\n\nn,m,k = map(int,input().split(" "))\n\na = deque(list(map(int,input().split())))\nb = deque(list(map(int,input().split())))\ncnt = 0\ntotal = 0\n\nif a[0]==True and b[0]==True:\n while total+a[0] < k or total+b[0] < k:\n if len(a) > 0 and len(b) > 0:\n picked = min(a[0],b[0])\n if picked == a[0]:\n total += a.popleft()\n if len(a)==0 or len(b)==0:\n break\n cnt += 1\n else:\n total += b.popleft()\n cnt += 1\nelif a[0] and b[0]==False:\n while total + a[0] < k:\n total +=a.popleft()\n if len(a) == 0:\n break\n cnt += 1\nelse:\n while total + b[0] < k:\n total += b.popleft()\n if len(b) == 0:\n break\n cnt += 1\n \nprint(cnt)', 'from collections import deque\n\nn,m,k = map(int,input().split(" "))\n\na = deque(list(map(int,input().split())))\nb = deque(list(map(int,input().split())))\ncnt = 0\ntotal = 0\n\nif a[0]==True and b[0]==True:\n while total+a[0] < k or total+b[0] < k:\n if len(a) > 0 and len(b) > 0:\n picked = min(a[0],b[0])\n if picked == a[0]:\n total += a.popleft()\n cnt += 1\n print(total,cnt)\n if len(a)==0: \n break\n else:\n total += b.popleft()\n cnt += 1\n print(total,cnt)\n if len(b)==0:\n break\nelif a[0] and b[0]==False:\n while total + a[0] < k:\n total +=a.popleft()\n cnt += 1\n if len(a) == 0:\n break\nelse:\n while total + b[0] < k:\n total += b.popleft()\n cnt += 1\n if len(b)==0:\n break\n \nprint(cnt)', '\n\n\n\n\n\nn, m, k = map(int, input().split())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\n\nacum1 = [0]\nfor i in range(n):\n acum1.append( arr1[-1] + arr1[i] )\n\nacum2 = [0]\nfor i in range(m):\n acum2.append( arr2[-1] + arr2[i])\n\nans = 0\nj = m\nfor i in range(n):\n if acum1[i] < k:\n break\n while acum1[i] + acum2[j] > k and acum2[j]>0: \n\n j -= 1\n ans = max(0,i+j)\n\nprint(ans)', 'n,m,k = map(int,input().split())\narr1 = list(map(int,input().split()))\narr2 = list(map(int,input().split()))\n\nacum1 = [0]\nfor i in range(n):\n acum1.append( acum1[-1] + arr1[i])\n\nacum2 = [0]\nfor i in range(m):\n acum2.append(acum2[-1] + arr2[i])\n\nans = 0\nj = m\nfor i in range(n+1):\n if acum1[i]>k:\n break\n while acum2[j]>k-acum1[i] and j>0:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s111329883', 's231178381', 's297547317', 's702207093', 's719433150', 's748626241', 's962542419', 's306048827'] | [41216.0, 47532.0, 41196.0, 41036.0, 40008.0, 42488.0, 41148.0, 47448.0] | [186.0, 285.0, 188.0, 176.0, 178.0, 187.0, 183.0, 292.0] | [577, 415, 579, 575, 840, 948, 581, 406] |
p02623 | u114641312 | 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 math import factorial,sqrt,ceil #,gcd\n# from itertools import permutations,combinations,combinations_with_replacement\n# from collections import deque,Counter\n# from bisect import bisect_left\n# from heapq import heappush,heappop\n# from numba import njit\n\n# from fractions import gcd\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\nimport numpy as np # numpy.lcm()\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n\n# import networkx as nx\n# G = Graph()\n\n\nMOD = 10**9 + 7\nN,M,K = map(int,input().split())\n# lisA = list(map(int,input().split()))\narrA = np.array([0] + list(map(int,input().split())))\narrB = np.array([0] + list(map(int,input().split())))\n\narrA = np.cumsum(arrA,dtype="int64")\narrB = np.cumsum(arrB,dtype="int64")\nprint(arrA)\nprint(arrB)\n\nmemo = np.add.outer(arrA,arrB) <= K\nprint(memo)\nj = M\nans = 0\nfor i in range(N+1):\n while j >= 0:\n if memo[i][j]:\n ans = max(i+j,ans)\n break\n j -= 1\n\nprint(ans)\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n', '# from math import factorial,sqrt,ceil #,gcd\n# from itertools import permutations,combinations,combinations_with_replacement\n# from collections import deque,Counter\n# from bisect import bisect_left\n# from heapq import heappush,heappop\n# from numba import njit\n\n# from fractions import gcd\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\nimport numpy as np # numpy.lcm()\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n\n# import networkx as nx\n# G = Graph()\n\n\nMOD = 10**9 + 7\nN,M,K = map(int,input().split())\n# lisA = list(map(int,input().split()))\narrA = np.array([0] + list(map(int,input().split())))\narrB = np.array([0] + list(map(int,input().split())))\n\narrA = np.cumsum(arrA,dtype="int64")\narrB = np.cumsum(arrB,dtype="int64")\n\n\nj = M\nans = 0\nfor i in range(N+1):\n while j >= 0:\n if arrA[i]+arrB[j] <= K:\n ans = max(i+j,ans)\n break\n j -= 1\n\nprint(ans)\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n'] | ['Runtime Error', 'Accepted'] | ['s782823983', 's840789340'] | [53816.0, 53760.0] | [249.0, 468.0] | [1434, 1410] |
p02623 | u116484168 | 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 = [int(i) for i in input().split()]\nB = [int(j) for j in 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 \n', 'N, M, K = map(int, input().split())\nA = [int(i) for i in input().split()]\nB = [int(j) for j in 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 \n'] | ['Runtime Error', 'Accepted'] | ['s098868253', 's172576771'] | [40508.0, 47340.0] | [124.0, 305.0] | [371, 371] |
p02623 | u125365353 | 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\nprint(a)\nprint(b)\n\nread = 0\ntime_ = 0\nai = 0\nbi = 0\n\nmax_read = 0\n\ndef readbook(time, read, ai, bi, isa):\n \n if isa:\n if ai < n:\n time += a[ai]\n else:\n return\n else:\n if bi < m:\n time += b[bi]\n else:\n return\n if time > k:\n return\n else:\n # readable\n read += 1\n global max_read\n if read > max_read:\n max_read = read\n\n readbook(time, read, ai + 1, bi, True)\n readbook(time, read, ai, bi + 1, False)\n\n\nreadbook(time_, read, ai, bi, True)\nread = 0\ntime_ = 0\nai = 0\nbi = 0\nreadbook(time_, read, ai, bi, False)\n\nif max_read !=0:\n max_read += 1\nprint(max_read)', '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\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# print(a)\n# print(b)\n\nans, j = 0, m\n\n# \nfor i in range(n+1):\n if a[i] > k:\n break\n\n \n while b[j] > k -a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s436255177', 's178302592'] | [39988.0, 47268.0] | [168.0, 303.0] | [810, 452] |
p02623 | u129749062 | 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()))\nAB = list()\nai = 0\nbi = 0\ntime = 0\nnum = 0\nleng = N + M\nprint(leng)\nfor _ in range(leng):\n if ai == len(A) and bi == len(B):\n break\n elif ai == len(A):\n AB.append(B[bi])\n bi += 1\n elif bi == len(B):\n AB.append(A[ai])\n ai += 1\n elif A[ai] <= B[bi]:\n AB.append(A[ai])\n ai += 1\n else:\n AB.append(B[bi])\n bi += 1\nif sum(AB) <= K:\n print(leng)\n sys.exit()\nfor i in range(leng):\n time += AB[i]\n if time <= K:\n num += 1\n else:\n break\nprint(num)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nna = len(A)\nnb = len(B)\ntotal_A = [0]\ntotal_B = [0]\nfor i in range(1,na+1):\n ta = total_A[i-1] + A[i-1]\n total_A.append(ta)\nfor i in range(1,nb+1):\n tb = total_B[i-1] + B[i-1]\n total_B.append(tb)\nans = 0\nb_start = 0\na = 0\ntotal = 0\nnna = na + 1\nnnb = nb + 1\nfor i in range(nna):\n a = total_A[i]\n for j in range(b_start,nnb):\n b = total_B[nnb-1-j]\n if a+b <= K:\n b_start = j\n total = i + (nnb-1-j)\n ans = max(ans,total)\n break\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s330764532', 's376102131'] | [40000.0, 49040.0] | [378.0, 399.0] | [594, 571] |
p02623 | u131881594 | 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()))\ntemp,temp2=0,0\nSa,Sb=[0]*n,[0]*m\nfor i in range(n):\n temp+=a[i]\n Sa[i]=temp\nfor i in range(m):\n temp2+=b[i]\n Sb[i]=temp2\nans,j=0,m-1\nfor i in range(n):\n if a[i]>k: break\n while a[i]+b[j]>k: 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()))\ntemp,temp2=0,0\nSa,Sb=[0]*n,[0]*m\nfor i in range(n):\n temp+=a[i]\n Sa[i]=temp\nfor i in range(m):\n temp2+=b[i]\n Sb[i]=temp2\ntemp=0\nflag=0\nans=0\nfor i in range(n-1,-1,-1):\n S=Sa[i]\n if S+Sb[temp]>k: break\n while S+Sb[temp]<=k:\n temp+=1\n if temp==m:\n flag=1\n break\n t=(i+1)+temp\n if t>ans: ans=t\n if flag: break\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(1,n+1): a[i]=a[i]+a[i-1]\nfor i in range(1,m+1): b[i]=b[i]+b[i-1]\nj=m\nans=0\nfor i in range(n+1):\n if j<0: break\n while a[i]+b[j]>k and j>=0: j-=1\n ans=max(i+j,ans)\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s377446780', 's599560709', 's751209930'] | [47324.0, 47640.0, 39828.0] | [257.0, 202.0, 283.0] | [341, 480, 303] |
p02623 | u135847648 | 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\ndef main():\n n, m, k = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n # A.reverse()\n # B.reverse()\n\n q_a = deque(A)\n q_b = deque(B)\n cnt = 0\n time = 0\n for _ in range(n + m):\n if q_a:\n a = q_a.popleft()\n else:\n a = None\n\n if q_b:\n b = q_b.popleft()\n else:\n b = None\n\n print(a,b)\n\n if a and b:\n \n if a < b:\n q_b.appendleft(b)\n time += a\n\n \n if b <= a:\n q_a.appendleft(a)\n time += b\n else:\n if a:\n time += a\n if b:\n time += b\n\n #print(q_a,q_b,time)\n \n if time > k:\n break\n\n cnt += 1\n\n print(cnt)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == "__main__":\n main()\n', '# from collections import deque\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n A = np.array([0] + list(map(int, input().split())))\n B = np.array([0] + list(map(int, input().split())))\n X = np.cumsum(A)\n Y = np.cumsum(B)\n P = X[X <= k]\n Q = Y[Y <= k]\n n = len(P)\n m = len(Q)\n # print(P,Q)\n\n cnt = 0\n if P[-1] + Q[-1] >= k:\n print(n + m - 2)\n exit()\n\n \n for i in range(n)[::-1]:\n if i + m <= cnt:\n break\n else:\n for j in range(m)[::-1]:\n #print(i,j,X[i],Y[j])\n if X[i] + Y[j] <= k:\n cnt = max(cnt, i + j)\n break\n print(cnt)\n\n\n\nif __name__ == "__main__":\n main()\n', '# from collections import deque\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n A = np.array([0] + list(map(int, input().split())))\n B = np.array([0] + list(map(int, input().split())))\n X = np.cumsum(A)\n Y = np.cumsum(B)\n P = X[X <= k]\n Q = Y[Y <= k]\n n = len(P)\n m = len(Q)\n # print(P,Q)\n\n cnt = 0\n \n for i in range(n):\n for j in range(m)[::-1]:\n print(i,j,X[i],Y[j])\n if X[i] + Y[j] <= k:\n cnt = max(cnt, i + j)\n break\n print(cnt)\n\n\n\nif __name__ == "__main__":\n main()\n', '# from collections import deque\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n A = np.array([0] + list(map(int, input().split())))\n B = np.array([0] + list(map(int, input().split())))\n X = np.cumsum(A)\n Y = np.cumsum(B)\n # print(P,Q)\n\n cnt = 0\n j = m\n \n for i, x in enumerate(X):\n if x > k:\n break\n\n while x + Y[j] > k:\n j -= 1\n cnt = max(cnt, i + j)\n\n print(cnt)\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s023229313', 's051478699', 's879444504', 's748644723'] | [40464.0, 53616.0, 54052.0, 53840.0] | [379.0, 231.0, 2252.0, 429.0] | [1031, 775, 623, 528] |
p02623 | u137038354 | 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]\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])\nans = 0\n\nt = 0\nfor i in range(0,N+1):\n p = min(t,M)\n if A[i] > K:\n break\n while B[p] > K - A[i]:\n p -= 1\n t = p\n ans = max(ans,i+p)\n\nprint(ans)', '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])\n\nfor i in range(M):\n B.append(B[i]+b[i])\nans = 0\n\np = M\nfor i in range(0,N+1):\n if A[i] > K:\n break\n while B[p] > K - A[i]:\n p -= 1\n ans = max(ans,i+p)\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s092821414', 's146714717'] | [47324.0, 47324.0] | [300.0, 283.0] | [380, 353] |
p02623 | u139441419 | 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\ns=0\nac=0\nbc=0\n\nfor i in range(n):\n s=s+a[i]\n ac=ac+1\n if s > k:\n s=s-a[i]\n ac=ac-1\n break\nfor i in range(m):\n s=s+b[i]\n bc=bc+1\n if s > k:\n s=s-b[i]\n bc=bc-1\n break\n\nprint(ac)\nprint(bc)\n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\ns=0\nac=0\nbc=0\nmax=0\n\nfor i in range(n):\n s=s+a[i]\n ac=ac+1\n if s > k:\n s=s-a[i]\n ac=ac-1\n break\nfor i in range(m):\n s=s+b[i]\n bc=bc+1\n if s > k:\n s=s-b[i]\n bc=bc-1\n break\n\nmax=ac+bc\n\nflag=0\nwhile flag==0 && ac!=0:\n ac=ac-1\n s=s-a[ac]\n while s <= k:\n bc=bc+1\n if bc > m:\n flag=1\n break\n s=s+b[bc-1]\n bc=bc-1\n if flag==0:\n s=s-b[bc-1]\n \n if max < ac+bc:\n max=ac+bc\n \nprint(max)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\ns=0\nac=0\nbc=0\nmax=0\n\nfor i in range(n):\n s=s+a[i]\n ac=ac+1\n if s > k:\n s=s-a[i]\n ac=ac-1\n break\nfor i in range(m):\n s=s+b[i]\n bc=bc+1\n if s > k:\n s=s-b[i]\n bc=bc-1\n break\n\nmax=ac+bc\n\nflag=0\nwhile flag==0 and ac!=0:\n ac=ac-1\n s=s-a[ac]\n while s <= k:\n bc=bc+1\n if bc > m:\n flag=1\n break\n s=s+b[bc-1]\n bc=bc-1\n if flag==0:\n s=s-b[bc]\n \n if max < ac+bc:\n max=ac+bc\n \nprint(max)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s031924766', 's423172824', 's449574655'] | [40752.0, 8832.0, 42216.0] | [189.0, 27.0, 318.0] | [308, 532, 532] |
p02623 | u141596821 | 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. | ["INF = float('inf')\nN, 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)\nfor i,x in enumerate(A):\n a[i+1] = a[i] + x\n\nfor i,x in enumerate(B):\n b[i+1] = b[i] + x\n\nans = 0\nfor i, va in enumerate(a):\n if va > K:\n break\n j = M\n while va + b[j] < K:\n #print(va, b[j], ans)\n j -= 1\n if j < 0:\n break\n ans = max(i+j, ans)\nprint(ans)\n", "def search(b, s, e, t):\n if e - s == 1:\n return s\n\n mid = (e + s) // 2\n\n if b[mid] <= t:\n return search(b, mid, e, t)\n else:\n return search(b, s, mid, t)\n\nINF = float('inf')\nN, 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)\nfor i,x in enumerate(A):\n a[i+1] = a[i] + x\n\nfor i,x in enumerate(B):\n b[i+1] = b[i] + x\n\nans = 0\nj = M\nfor i, va in enumerate(a):\n if va > K:\n break\n index = search(b, 0, len(b), K-va)\n ans = max(i+index, ans)\nprint(ans)\n\n\n\n\n"] | ['Wrong Answer', 'Accepted'] | ['s470141599', 's790138503'] | [48744.0, 47660.0] | [2206.0, 963.0] | [477, 602] |
p02623 | u143441425 | 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()))\nns = list(map(int, input().split()))\nms = list(map(int, input().split()))\n\nnss = [0]\nfor i, v in enumerate(ns):\n nss.append(nss[i] + ns[i])\n\nmss = [0]\nfor i, v in enumerate(ms):\n mss.append(mss[i] + ms[i])\n\nmx = 0\nj = m\nfor i in range(n + 1):\n if nss[i] > k:\n break\n\n while mss[j] > k - nss[i]:\n j -= 1\n \n print(i, j)\n\n mx = max(mx, i + j)\n\nprint(mx)\n', 'n, m, k = list(map(int, input().split()))\nns = list(map(int, input().split()))\nms = list(map(int, input().split()))\n\nnss = [0]\nfor i, v in enumerate(ns): nss.append(nss[i] + ns[i])\nmss = [0]\nfor i, v in enumerate(ms): mss.append(mss[i] + ms[i])\n\nfrom bisect import bisect_left\n\nmx = 0\nfor i in range(n + 1):\n if nss[i] > k:\n break\n\n v = k - nss[i]\n j = bisect_left(mss, v)\n print(i, nss, j, mss, k)\n if j < m and mss[j] != v:\n j -= 1\n\n mx = max(mx, i + j)\n\nprint(mx)\n', 'n, m, k = list(map(int, input().split()))\nns = list(map(int, input().split()))\nms = list(map(int, input().split()))\n\nimport numpy as np\nimport bisect\n\nnss = np.array([0] + ns).cumsum()\nmss = np.array([0] + ms).cumsum()\nmx = 0\nfor i in range(n + 1):\n if nss[i] > k:\n break\n j = bisect.bisect_right(mss, k - nss[i])\n if j > 0:\n j -= 1\n mx = max(mx, i + j)\nprint(mx)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s373381058', 's401334619', 's914760381'] | [47296.0, 174768.0, 47308.0] | [395.0, 1634.0, 797.0] | [428, 499, 390] |
p02623 | u143903328 | 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\nsumA = []\nsumB = []\ntmp = 0\nanswer = 0\nst = 1\n\nfor i in range(N):\n tmp = tmp + A[i]\n sumA.append(tmp)\n\ntmp = 0\nfor i in range(M):\n tmp = tmp + B[i]\n sumB.append(tmp)\n\nfor i in range(N, 0, -1):\n booktmp = 0\n\n for j in range(st , M + 1):\n\n if sumA[i-1] + sumB[j-1] <= K:\n booktmp = i + j\n st = st + 1\n else:\n st = st - 1\n break\n answer = max(answer, booktmp)\n\n\nprint(answer)\n\n\n', 'N, M, K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nsumA = [0]\nsumB = [0]\ntmp = 0\nanswer = 0\nst = 0\n\nfor i in range(N):\n tmp = tmp + A[i]\n sumA.append(tmp)\n\ntmp = 0\nfor i in range(M):\n tmp = tmp + B[i]\n sumB.append(tmp)\n\nfor i in range(N, -1, -1):\n booktmp = 0\n\n for j in range(st, M + 1):\n\n if sumA[i] + sumB[j] <= K:\n booktmp = i + j\n else:\n st = j\n break\n answer = max(answer, booktmp)\n if j == M:\n break\n\n\nprint(answer)\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s902485671', 's155756042'] | [48572.0, 48488.0] | [407.0, 373.0] | [560, 558] |
p02623 | u150788544 | 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()))\nt = k\nstart = 0\nwhile True:\n if start == len(b):\n break\n else:\n if t - b[start] < 0:\n break\n else: \n t -= b[start]\n start += 1\n\nnum = start\nlst = [0]\nM = 0\nprint(start,t)\nfor i in range(len(a)):\n while a[i] > t:\n b_ = b.pop()\n t = t+b_\n num -= 1\n t -= a[i]\n num += 1\n print(num,t)\n \n if lst[-1] < num:\n M = num\n lst.append(num) \n \nprint(M) \n ', 'import sys\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nb2 = []\nt = k\nstart = 0\nwhile True:\n if start == len(b):\n break\n else:\n if t - b[start] < 0:\n break\n else: \n t -= b[start]\n b2.append(b[start])\n start += 1\nnum = start\nlst = [start]\nM = start\n\nfor i in range(len(a)):\n if a[i] > t and b2 == []:\n print(M)\n sys.exit()\n while a[i] > t and b2 != []:\n b_ = b2.pop()\n t = t+b_\n num -= 1\n \n if a[i] <= t:\n t -= a[i]\n num += 1\n \n \n if M < num:\n M = num\n lst.append(num) \n \n \n \n \n \nprint(M) \n '] | ['Runtime Error', 'Accepted'] | ['s188326607', 's494799254'] | [40500.0, 40600.0] | [398.0, 324.0] | [511, 627] |
p02623 | u152614052 | 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\n\nn,m,k = map(int,input().split())\nli_a = list(map(int,input().split()))\nli_b = list(map(int,input().split()))\n\nli_A = numpy.cumsum(li_a)\nli_B = numpy.cumsum(li_b)\n\nans, j = 0,m\nfor i in range(n + 1):\n if li_A[i] > k:\n break\n while li_B[j] + li_A[i]> k:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'import numpy\n\nn,m,k = map(int,input().split())\nli_a = list(map(int,input().split()))\nli_b = list(map(int,input().split()))\n\nli_A = [0] + list(numpy.cumsum(li_a))\nli_B = [0] + list(numpy.cumsum(li_b))\n\nans, j = 0,m\nfor i in range(n+1):\n if li_A[i] > k:\n break\n while li_B[j] + li_A[i]> k:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s456399687', 's943027635'] | [58296.0, 60780.0] | [241.0, 517.0] | [330, 352] |
p02623 | u157020659 | 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 = 0\ncnt = 0\ncost = 0\nfor i, x in enumerate(a):\n cost += x\n if cost > k:\n cnt = i\n cost -= x\n break\nelse:\n for j, y in enumerate(b):\n cost += y\n if cost > k:\n cnt = n + j\n cost -= y\n break\n else:\n ans = n + m\n\nif cnt <= n:\n i, j = cnt - 1, 0\nelse:\n i, j = n - 1, cnt - n + 1\n\nwhile True:\n if cost == 0: break\n cost += - a[i] + b[j]\n i, j = i - 1, j + 1\n while cost + b[j] <= k:\n j += 1\n cnt += 1\n if cost > k: break\nif ans != 0:\n print(ans)\nelse:\n print(cnt)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nj = m - 1\ncost = sum(b)\ncnt = m\nans = 0\nfor i in range(n + 1):\n if i != 0:\n cost += a[i - 1]\n cnt += 1\n while cost > k and j >= 0:\n cost -= b[j]\n cnt -= 1\n j -= 1\n if cost <= k:\n ans = max(cnt, ans)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s176630661', 's854024772'] | [39760.0, 40480.0] | [259.0, 241.0] | [698, 369] |
p02623 | u157232135 | 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 as it\ndef main():\n n,m,k=map(int,input().split())\n a = list(it.accumulate(map(int, input().split())))\n b = list(it.accumulate(map(int, input().split())))\n ans = []\n for A in range(n-1,-1,-1):\n print("A", A)\n aa = a[A]\n Kaa = k-aa\n for B in range(m-1,-1,-1):\n print("B", B)\n if b[B] <= Kaa:\n ans.append(A+B+2)\n break\n print(max(ans) if len(ans) > 0 else 0)\n \nif __name__ == \'__main__\':\n main()', "import itertools as it\ndef main():\n n,m,k=map(int,input().split())\n a = [0]\n a.extend(it.accumulate(map(int, input().split())))\n b = [0]\n b.extend(it.accumulate(map(int, input().split())))\n \n ans = 0\n M = m\n for A in range(n+1):\n aa = a[A]\n Kaa = k-aa\n if Kaa < 0:\n break\n for B in range(M,-1,-1):\n if b[B] <= Kaa:\n ans = max(ans, A+B)\n M = B\n break\n print(ans)\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s603864578', 's974874113'] | [70924.0, 45696.0] | [2285.0, 232.0] | [513, 525] |
p02623 | u159144188 | 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_timelist = int(input().split())\nb_timelist = int(input().split())\ncounta = len(a_timelist)\ncountb = len(b_timelist)\ntime = 0\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + a_timelist[i])\nfor i in range(M):\n b.append(b[i] + b_timelist[i])\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)\nN, M, K = int(input().split())\na_timelist = int(input().split())\nb_timelist = int(input().split())\ncounta = len(a_timelist)\ncountb = len(b_timelist)\ntime = 0\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + a_timelist[i])\nfor i in range(M):\n b.append(b[i] + b_timelist[i])\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提出情報', '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)', 'N, M, K = map(int, (input().split()))\na_timelist = int(input().split())\nb_timelist = int(input().split())\ncounta = len(a_timelist)\ncountb = len(b_timelist)\ntime = 0\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + a_timelist[i])\nfor i in range(M):\n b.append(b[i] + b_timelist[i])\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)\nN, M, K = int(input().split())\na_timelist = int(input().split())\nb_timelist = int(input().split())\ncounta = len(a_timelist)\ncountb = len(b_timelist)\ntime = 0\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + a_timelist[i])\nfor i in range(M):\n b.append(b[i] + b_timelist[i])\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 = int(input().split())\na_timelist = int(input().split())\nb_timelist = int(input().split())\ncounta = len(a_timelist)\ncountb = len(b_timelist)\ntime = 0\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + a_timelist[i])\nfor i in range(M):\n b.append(b[i] + b_timelist[i])\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()))\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', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s091423717', 's114635098', 's458484095', 's968538753', 's411004576'] | [25532.0, 8792.0, 25596.0, 8940.0, 47544.0] | [43.0, 26.0, 43.0, 27.0, 283.0] | [833, 340, 822, 407, 342] |
p02623 | u159723084 | 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\nans=0\nT=0\nfor i in range(N):\n T+=A[i]\n if T > K:\n T-=A[i]\n ans-=1\n break\n else:\n ans+=1\nR=[]\nR.append(ans)\nn=ans\nm=0\nwhile(1):\n while(1):\n if m>=M: break\n T+=B[m]\n \n if T > K:\n T-=B[m]\n break\n else:\n ans+=1\n R.append(ans)\n m+=1\n \n n-=1\n if n<0: break\n T-=A[n]\n ans-=1\n \n\nprint(max(R))', '# -*- coding: utf-8 -*-\nN,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nans=0\nT=0\nfor i in range(N):\n T+=A[i]\n if T > K:\n T-=A[i]\n break\n else:\n ans+=1\nR=[]\nR.append(ans)\nn=ans\nm=0\nwhile(1):\n while(1):\n if m>=M: break\n T+=B[m]\n \n if T > K:\n T-=B[m]\n break\n else:\n ans+=1\n R.append(ans)\n m+=1\n \n n-=1\n if n<0: break\n T-=A[n]\n ans-=1\n \n\nprint(max(R))'] | ['Wrong Answer', 'Accepted'] | ['s489072065', 's115112024'] | [40572.0, 42192.0] | [290.0, 317.0] | [562, 547] |
p02623 | u161164709 | 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\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\n\nnum = 0\nJ = M\nfor i in range(N+1):\n if A_sum[i] > K:\n break\n for j in (J,0,-1):\n if A_sum[i] + B_sum[j] <= K:\n if num < i+j:\n num = i+j\n J = j\n break\n\nprint(num)', 'N, M, K = list(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\n\nnum = 0\nJ = M\nfor i in range(N+1):\n if A_sum[i] > K:\n break\n for j in (J,-1,-1):\n if A_sum[i] + B_sum[j] <= K:\n if num < i+j:\n num = i+j\n J = j\n break\n\nprint(num)\n', 'N, M, K = list(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\nnum = 0\nJ = M\nfor i in range(N+1):\n if A_sum[i] > K:\n break\n for j in reversed(range(J+1)):\n if A_sum[i] + B_sum[j] <= K:\n if num < i+j:\n num = i+j\n J = j\n break\n\nprint(num)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s249026014', 's293591243', 's132578110'] | [47468.0, 47512.0, 47672.0] | [264.0, 274.0, 342.0] | [472, 474, 484] |
p02623 | u163501259 | 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\ninput = sys.stdin.readline\nfrom collections import deque\ndef main():\n N, M, K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n i, j = 0, 0\n while K > 0:\n print(i,j)\n if i == N:\n if j != M:\n read = B[j]\n if K >= read:\n K -= read\n j += 1\n else:\n break\n else:\n i = N\n j = M\n break\n\n elif j == M:\n if i != N:\n read = A[i]\n if K >= read:\n K -= read\n i += 1\n else:\n break\n else:\n i = N\n j = M\n break\n else:\n if A[i] >= B[j]:\n read = B[j]\n if K >= read:\n K -= read\n j += 1\n else:\n break\n else:\n read = A[i]\n if K >= read:\n K -= read\n i += 1\n else:\n break\n print(i+j)\n\nif __name__ == '__main__':\n main()", "import sys\ninput = sys.stdin.readline\nfrom collections import deque\ndef main():\n N, M, K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n As = [0]*(N+1)\n Bs = sum(B)\n As[0] = 0\n for i in range(1,N):\n As[i] = As[i-1] + A[i-1]\n T = K\n j = M \n ans = 0\n for i in range(N):\n T = K - A[i]\n if T < 0:\n break\n while Bs > T:\n j -= 1\n Bs -= B[j]\n ans = max(ans, i+j+1)\n print(ans)\n\nif __name__ == '__main__':\n main()", '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', 'Wrong Answer', 'Accepted'] | ['s240121036', 's514389196', 's680240386'] | [41920.0, 41964.0, 47488.0] | [354.0, 205.0, 290.0] | [1273, 567, 344] |
p02623 | u163543660 | 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\nn,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nasum=[0]\nbsum=[0]\nfor i in range(n):\n asum.append(asum[-1]+a[i])\nfor i in range(m):\n bsum.append(bsum[-1+b[i]])\nans=0\nfor i in range(n+1):\n if asum[i]>0:\n break\n while asum[i]+bsum[m]>0 and m>0:\n m-=1\n ans=(ans,i+m)\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nasum=[0]\nbsum=[0]\nfor i in range(n):\n asum.append(asum[-1]+a[i])\nfor i in range(m):\n bsum.append(bsum[-1]+b[i])\nans=0\nfor i in range(n+1):\n if asum[i]>k:\n break\n while asum[i]+bsum[m]>k and m>0:\n m-=1\n ans=max(ans,i+m)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s354449106', 's091887159'] | [40588.0, 47344.0] | [141.0, 302.0] | [355, 355] |
p02623 | u165368960 | 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]\nfor i in range(n):\n a_sum.append(a[i] + a_sum[i])\nb_sum = [0]\nfor i in range(m):\n b_sum.append(b[i] + b_sum[i])\n\nans = 0\nfor i in range(n+1):\n if a[i] > k:\n break\n for j in range(m+1):\n if a_sum[i] + b_sum[j] <= k:\n ans = max(ans, i + j)\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()))\n\na_sum = [0]\nfor i in range(n):\n a_sum.append(a[i] + a_sum[i])\nb_sum = [0]\nfor i in range(m):\n b_sum.append(b[i] + b_sum[i])\n \nans = 0\nj = m\nfor i in range(n+1):\n if a_sum[i] > k:\n break\n while a_sum[i] + b_sum[j] > k:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s942250660', 's378141489'] | [47660.0, 47328.0] | [2207.0, 286.0] | [406, 380] |
p02623 | u165394332 | 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\n\nN, M, K = map(int, input().split())\na = list(accumulate(int(i) for i in input().split(), initial=0))\nb = list(accumulate(int(i) for i in input().split(), initial=0))\n\ncnt = 0\nbest0 = M\nfor i in range(N+1):\n ai = a[i]\n for j in range(best0, -1, -1):\n bj = b[j]\n if ai + bj <= K:\n cnt = max(cnt, i + j)\n best0 = j\n break\n\nprint(cnt)', 'from itertools import accumulate\n\nN, M, K = map(int, input().split())\na = [0] + list(accumulate(int(i) for i in input().split()))\nb = [0] + list(accumulate(int(i) for i in input().split()))\n\ncnt = 0\nbest0 = M\nfor i in range(N+1):\n ai = a[i]\n for j in range(best0, -1, -1):\n bj = b[j]\n if ai + bj <= K:\n cnt = max(cnt, i + j)\n best0 = j\n break\n\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s634897279', 's717104582'] | [9124.0, 45752.0] | [24.0, 309.0] | [417, 407] |
p02623 | u167908302 | 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\nimport itertools\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\nj = m\n\naa = [0] + list(itertools.accumulate(a))\nbb = [0] + list(itertools.accumulate(b))\n#print(aa)\n#print(bb)\n\n\n\nfor i, a_item in enumerate(a):\n if a_item > k:\n break\n while a_item + b[j] > k:\n j -= 1\n ans = max(i + j, ans)\nprint(ans)\n', '# coding:utf-8\nimport itertools\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\nj = m\n\naa = [0] + list(itertools.accumulate(a))\nbb = [0] + list(itertools.accumulate(b))\n# print(aa)\n# print(bb)\n\n\n\nfor i, a_item in enumerate(aa):\n if a_item > k:\n break\n while a_item + bb[j] > k:\n j -= 1\n ans = max(i + j, ans)\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s103178919', 's761237773'] | [50532.0, 50564.0] | [147.0, 236.0] | [510, 514] |
p02623 | u169165784 | 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\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nacc_a = [0]\nfor i in range(N):\n acc_a.append(acc_a[i] + A[i])\n\nacc_b = [0]\nfor i in range(M):\n acc_b.append(acc_b[i] + B[i])\n\nacc_a = numpy.array(acc_a)\nacc_b = numpy.array(acc_b)\n\ncurrentMax = 0\nfor j in range(M + 1):\n tB = acc_b[j]\n remain = K - tB\n # print('-----------')\n \n if remain < 0:\n \n break\n\n print(numpy.where(acc_a < remain)[0])\n if len(numpy.where(acc_a < remain)[0]) != 0:\n readable = numpy.where(acc_a <= remain)[0][-1]\n\n \n \n currentMax = max(currentMax, j + readable)\n\nprint(currentMax)", 'import numpy\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nacc_a = [0]\nfor i in range(N):\n acc_a.append(acc_a[i] + A[i])\n\nacc_b = [0]\nfor i in range(M):\n acc_b.append(acc_b[i] + B[i])\n\nacc_a = numpy.array(acc_a)\nacc_b = numpy.array(acc_b)\n\ncurrentMax = 0\nbnum = M\nfor anum in range(N + 1):\n if acc_a[anum] > K:\n break\n\n while True:\n if acc_b[bnum] > K - acc_a[anum]:\n bnum = bnum - 1 \n else:\n break\n\n currentMax = max(currentMax, anum + bnum)\n\n\nprint(currentMax)'] | ['Wrong Answer', 'Accepted'] | ['s751465637', 's920338798'] | [66864.0, 66612.0] | [2207.0, 607.0] | [985, 584] |
p02623 | u171654347 | 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())\n\nalist = input().split()\nblist = input().split()\n\nprint(alist)\nprint(blist)\n\nwork = k\nacount = 0\nwhile (acount < n) and (work >= int(alist[acount])):\n work -= int(alist[acount])\n acount += 1\n\nmaxCount = acount\nbCount = 0\nfor num in range(0, acount):\n if (num > 1):\n work += int(alist[acount-num])\n\n while (bCount < m) and (work >= int(blist[bCount])):\n work -= int(blist[bCount])\n bCount += 1\n maxCount = max(maxCount, acount-num+bCount)\n\n\n\n\nprint(maxCount)\n', '# -*- coding: utf-8 -*-\nn, m, k = map(int, input().split())\n\nalist = input().split()\nblist = input().split()\n\nwork = k\nacount = 0\nwhile (acount < n) and (work >= int(alist[acount])):\n work -= int(alist[acount])\n acount += 1\n\nbCount = 0\nwork2 = work\nwhile (bCount < m) and (work2 >= int(blist[bCount])):\n work2 -= int(blist[bCount])\n bCount += 1\n\n\nmaxCount = acount + bCount\nbCount = 0\nfor num in range(0, acount):\n work += int(alist[acount-num-1])\n\n while (bCount < m) and (work >= int(blist[bCount])):\n work -= int(blist[bCount])\n bCount += 1\n maxCount = max(maxCount, acount-num-1+bCount)\n\n\nprint(maxCount)'] | ['Wrong Answer', 'Accepted'] | ['s273830160', 's006381860'] | [45488.0, 40472.0] | [457.0, 499.0] | [554, 651] |
p02623 | u174181999 | 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\nfor i in range(n-1):\n a[i+1] = a[i] + a[i+1]\na.insert(0, 0)\nfor i in range(m-1):\n b[i+1] = b[i] + b[i+1]\nb.insert(0, 0)\nprint(a)\nprint(b)\nx = 0\nfor i in range(n+1):\n for j in range(m+1):\n if b[m-j] > k-a[i]:\n pass\n else:\n jmax = m-j\n if jmax + i > x:\n x = jmax + i\nprint(x)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfor i in range(n-1):\n a[i+1] = a[i] + a[i+1]\na.insert(0, 0)\nfor i in range(m-1):\n b[i+1] = b[i] + b[i+1]\nb.insert(0, 0)\n\nx = 0\njmax = m\nfor i in range(n+1):\n for j in range(jmax, -1, -1):\n if b[j] > k-a[i]:\n pass\n else:\n jmax = j\n if jmax + i > x:\n x = jmax + i\n break\nprint(x)'] | ['Wrong Answer', 'Accepted'] | ['s750439994', 's967660122'] | [41492.0, 40680.0] | [2214.0, 315.0] | [451, 468] |
p02623 | u178946688 | 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]\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 = 0\nm = M\nfor n in range(N + 1):\n while True:\n time = A[n] + B[m]\n if time <= K:\n ans = max(ans, n + m)\n break\n else:\n j -= 1\nprint(ans)', '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 \nans = 0\nj = M\nfor n in range(N + 1):\n while True:\n time = A[n] + B[j]\n if time > K:\n j -= 1\n else:\n ans = max(ans, n + j)\n break\nprint(ans)', '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 \nans = 0\nj = M\nfor n in range(N + 1):\n while B[j] > K - A[n]:\n j -= 1\n ans = max(ans, n + j)\nprint(ans)', '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 \nans = 0\nj = M\nfor n in range(N + 1):\n if A[n] > K:\n break\n while B[j] > K - A[n]:\n j -= 1\n ans = max(ans, n + j)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s058974132', 's136655557', 's709131673', 's562731202'] | [47572.0, 47668.0, 47460.0, 47376.0] | [250.0, 326.0, 308.0, 303.0] | [379, 378, 323, 348] |
p02623 | u182178426 | 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\na = list(accumulate(a))\nb = list(accumulate(b))\n\nfrom collections import deque\nu = deque([0])\na.append(0)\n\nimport bisect\nfor i in range(n+1):\n if k-a[i]>=0:\n index = bisect.bisect_left(b,k-a[i])\n u.append(index+i)\n else:\n break\nprint(max(u))\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\na = list(accumulate(a))\nb = list(accumulate(b))\n\nfrom collections import deque\nu = deque([0])\na.insert(0,0)\n\nimport bisect\nfor i in range(n+1):\n if k-a[i]>=0:\n index = bisect.bisect_right(b,k-a[i])\n u.append(index+i)\n else:\n break\nprint(max(u))'] | ['Wrong Answer', 'Accepted'] | ['s009743237', 's133315706'] | [40440.0, 40356.0] | [280.0, 291.0] | [406, 408] |
p02623 | u185948224 | 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.append(2*10**10)\nB.append(2*10**10)\nA.append(2*10**10)\nB.append(2*10**10)\n \nans = 0\nt = 0\nia, ib = 0, 0\nwhile t < K and (ia < N or ib < M):\n if A[ia] + A[ia+1] <= B[ib] + B[ib+1]:\n if t + A[ia] <= K:\n t += A[ia]\n ans += 1\n ia += 1\n else: break\n else:\n if t + B[ib] <= K:\n t += B[ib]\n ans += 1\n ib += 1\n else: break\n print(t, ia, ib, ans)\n \nprint(ans)', 'from bisect import bisect_left\nN, M ,K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA =[A[0]]\nfor i in A[1:]:\n SA.append(SA[-1] + i)\nSB =[0]\nfor i in B:\n SB.append(SB[-1] + i)\n\ni = bisect_left(SA, K)\nSA = SA[: i+1]\nSA.append(2*10**9)\ni = bisect_left(SB, K)\nSB = SB[: i+1]\nif SB[-1] > K: SB.pop()\n\ni, ii = 0, 0\nj = len(SB) - 1\nans = [j]\nwhile j >= 0:\n diff = K - SB[j]\n jdg = False\n for ii in range(i, len(SA)):\n if SA[ii] > diff:\n jdg = True\n break\n i = ii\n ans.append(i + j)\n j -= 1\nprint(max(ans))'] | ['Wrong Answer', 'Accepted'] | ['s863560533', 's586227891'] | [40444.0, 50244.0] | [735.0, 320.0] | [563, 608] |
p02623 | u189487046 | 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\naa = [0]*(N+1)\nfor i in range(1, N+1):\n aa[i] = aa[i-1]+A[i-1]\n\nbb = [0]*(M+1)\nfor i in range(1, M+1):\n bb[i] = bb[i-1]+B[i-1]\n\nans = 0\nfor i in range(N+1):\n tmp_K = K-aa[i]\n if tmp_K == 0:\n ans = max(ans, i)\n elif tmp_K < 0:\n continue\n\n if tmp_K <= bb[-1]:\n ans = max(ans, i+M)\n mn = 0\n mx = M\n while True:\n if mn == mx:\n if tmp_K >= bb[mn]:\n ans = max(ans, i+mn)\n break\n\n mid = (mn+mx//2)\n if bb[mid] <= tmp_K:\n if mn == mid:\n mn = mid+1\n else:\n mn = mid\n else:\n if mx == mid:\n mx = mid-1\n else:\n mx = mid\nprint(ans)\n', 'import itertools\nimport bisect\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\naa = [0] + list(itertools.accumulate(A))\nbb = [0] + list(itertools.accumulate(B))\n\nans = bisect.bisect_left(aa, K)-1\nans = max(ans, bisect.bisect_left(bb, K)-1)\n\nfor i in reversed(range(N+1)):\n tmp_K = K-aa[i]\n if tmp_K == 0:\n ans = max(ans, i)\n elif tmp_K < 0:\n continue\n\n if i + M <= ans:\n continue\n\n if tmp_K >= bb[-1]:\n ans = max(ans, i+M)\n continue\n\n ans = max(ans, bisect.bisect_left(bb, tmp_K)-1+i)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s257642187', 's931129728'] | [48920.0, 50652.0] | [2207.0, 318.0] | [845, 611] |
p02623 | u190850294 | 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\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\n\nmod = 10 ** 9 + 7\n\nN, M, K = LS()\ndesk = LSR(2)\na, b = [0], [0]\n\n# a = [0, 0 + A1, 0 + A1 + A2, ....]\n# b = [0, 0 + B1, 0 + B1 + B2, ....]\nfor i in range(N):\n a.append(a[i] + desk[0][i])\nfor j in range(M):\n b.append(b[j] + desk[1][j])\n\n\n\nans, j = 0, M \n\nfor i in range(N + 1):\n if a > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)", "import sys\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\n\nmod = 10 ** 9 + 7\n\nN, M, K = LI()\ndesk = LIR(2)\na, b = [0], [0]\n\n# a = [0, 0 + A1, 0 + A1 + A2, ....]\n# b = [0, 0 + B1, 0 + B1 + B2, ....]\nfor i in range(N):\n a.append(a[i] + desk[0][i])\nfor j in range(M):\n b.append(b[j] + desk[1][j])\n\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)"] | ['Runtime Error', 'Accepted'] | ['s657136273', 's570078117'] | [42112.0, 47540.0] | [74.0, 292.0] | [1145, 1148] |
p02623 | u193880030 | 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 = 0\ncount = 0\nfor _ in range(n + m):\n if len(a) > 0and len(b)>0:\n if a[-1] < b[-1]:\n time += a[-1]\n a = a[:-1]\n else:\n time += b[-i-1]\n b = b[:-1]\n elif len(a) == 0 and len(b) > 0:\n time += b[-1]\n b = b[:-1]\n elif len(b) == 0 and len(a) > 0:\n time += a[-1]\n a = a[:-1]\n if time > k:\n break\n else:\n count += 1\n \n \nprint(count)', 'n, m, k = map(int, input().split())\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ntime = 0\ncount = 0\nfor _ in range(n + m):\n if len(a) > 0 and len(b)>0:\n if a[0] < b[0]:\n time += a[0]\n a = a[1:]\n else:\n time += b[0]\n b = b[1:]\n elif len(a) == 0 and len(b) > 0:\n time += b[0]\n b = b[]\n elif len(b) == 0 and len(a) > 0:\n time += a[0]\n a = a[:-1]\n if time > k:\n break\n else:\n count += 1\n \n \nprint(count)', 'n, m, k = map(int, input().split())\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ntime = 0\ncount = 0\nfor _ in range(n + m):\n if len(a) > 0and len(b)>0:\n if a[-1] < b[-1]:\n time += a[-1]\n a = a[:-1]\n else:\n time += b[-1]\n b = b[:-1]\n elif len(a) == 0 and len(b) > 0:\n time += b[-1]\n b = b[:-1]\n elif len(b) == 0 and len(a) > 0:\n time += a[-1]\n a = a[:-1]\n if time > k:\n break\n else:\n count += 1\n \n \nprint(count)', 'n, m, k = map(int, input().split())\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ntime = 0\ncount = 0\nfor _ in range(n * m):\n if len(a) > 0and len(b)>0:\n if a[-1] < b[-1]:\n time += a[-1]\n a = a[:-1]\n else:\n time += b[-i-1]\n b = b[:-1]\n elif len(a) == 0:\n time += b[-1]\n b = b[:-1]\n elif len(b) == 0:\n time += a[-1]\n a = a[:-1]\n if time > k:\n print(count)\n break\n else:\n count += 1\n \n', 'n, m, k = map(int, input().split())\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ntime = 0\ncount = 0\nfor _ in range(N * M):\n if a[-1] < b[-1]:\n time += a[-1]\n a = a[:-1]\n else:\n time += b[-i-1]\n b = b[:-1]\n if time > k:\n print(count)\n break\n else:\n count += 1\n', 'n, m, k = map(int, input().split())\n\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', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s061596050', 's273507718', 's301800926', 's527105831', 's851596440', 's155139876'] | [41772.0, 9000.0, 40760.0, 40752.0, 40444.0, 47408.0] | [2206.0, 29.0, 2206.0, 2206.0, 116.0, 306.0] | [569, 557, 567, 539, 349, 356] |
p02623 | u201986772 | 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_left\n \nn,m,k=map(int,input().split())\na=list(accumulate([0]+list(map(int,input().split()))))\nb=list(accumulate([0]+list(map(int,input().split()))))\nmx=0\nfor i in range(n+1):\n idx=bisect_left(b,max(k-a[i],0))\n mx=max(mx,i+idx)\nprint(mx)\n ', "from itertools import accumulate\nfrom bisect import bisect_left\n \nn,m,k=map(int,input().split())\na=list(accumulate([0]+list(map(int,input().split()))))\nb=list(accumulate([0]+list(map(int,input().split()))))\n#print(b)\nmx=0\nfor i in range(n+1):\n if a[i]>k:continue\n #print('a[i];'+str(a[i]))\n idx=min(bisect_left(b,k-a[i]),m)\n #print(idx)\n if b[idx]>k-a[i]:idx-=1\n if a[i]+b[idx]>k:continue\n mx=max(mx,i+idx)\nprint(mx)\n "] | ['Wrong Answer', 'Accepted'] | ['s148639157', 's031737516'] | [42920.0, 42912.0] | [294.0, 365.0] | [299, 426] |
p02623 | u202634017 | 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\nfor i in range(1, n):\n a[i] += a[i - 1]\n\nfor i in range(1, m):\n b[i] += b[i - 1]\n\nptr = 0\nans = 0\n\nfor i in range(n):\n if a[i] > k:\n break\n while ptr < m:\n if a[i] + b[ptr] >= k:\n break\n ptr += 1\n print(i, ptr)\n ans = max(ans, i + min(ptr, m) + 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]\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\nptr = m\nans = 0\n\nfor i in range(n + 1):\n if a[i] > k:\n break\n while a[i] + b[ptr] > k:\n ptr -= 1\n ans = max(ans, i + ptr)\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s722544676', 's686894825'] | [40556.0, 47536.0] | [418.0, 285.0] | [419, 371] |
p02623 | u203239974 | 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 get_sum_arr(arr):\n sum_arr = [0]\n N = len(arr)\n for i in range(1,N+1):\n sum_arr.append(sum_arr[i-1] + arr[i-1])\n return sum_arr\ndef get_max_book_num(A,B,K):\n A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)\n count,i,j = 0,0,0\n for i in range(0,len(A_sum_arr)):\n if K < A_sum_arr[i]:\n break\n else:\n print("A:",A_sum_arr[:i])\n j = 0\n while B_sum_arr[j] <= (K - A_sum_arr[i]):\n print("B:",B_sum_arr[:j])\n j += 1\n if j >= len(B_sum_arr):\n break\n j -= 1\n count = max(count,(i+j))\n return count\n\nif __name__ == "__main__":\n N,M,K = list(map(int,input().split()))\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)\n print(get_max_book_num(A,B,K))\n \n', 'if __name__ == "__main__":\n N,M,K = list(map(int,input().split()))\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n count,i_a,i_b = 0,0,0\n # ADD A item\n for i_a in range(len(A)):\n if K < A[i_a]:\n break\n else:\n count += 1\n K -= A[i_a]\n # replace B item\n \n for i in range((i_a-1),-1,-1):\n K += A[i]\n if i_b >= len(B):\n break\n while True:\n if i_b >= len(B):\n break\n if K < B[i_b] :\n break\n else :\n K -= B[i_b]\n i_b += 1\n count = max(count,((i+1)+(i_b+1)))\n print(count)', 'if __name__ == "__main__":\n N,M,K = list(map(int,input().split()))\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n count,i_a,i_b = 0,0,0\n # ADD A item\n for i_a in range(len(A)):\n if K < A[i_a]:\n i_a -= 1\n break\n else:\n K -= A[i_a]\n # replace B item\n for i_b in range(len(B)):\n if K < B[i_b] :\n i_b -= 1\n break\n else :\n K -= B[i_b]\n \n count = (i_a+1) + (i_b+1) \n \n \n \n print("{}+{}={}".format(i_a,i_b,count))\n for i in range(i_a,-1,-1): \n K += A[i] \n\n j = 0\n for j in range(i_b+1,len(B)):\n if K < B[j]:\n j -= 1\n else :\n K -= B[j]\n print("i_a:{},i_b:{}".format(i,i_b))\n i_b = j\n \n \n count = max(count,(i+i_b))\n print(count)', 'if __name__ == "__main__":\n N,M,K = list(map(int,input().split()))\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n count,i_a,i_b = 0,0,0\n # ADD A item\n for i_a in range(len(A)):\n if K < A[i_a]:\n i_a -= 1\n break\n else:\n K -= A[i_a]\n # replace B item\n for i_b in range(len(B)):\n if K < B[i_b] :\n i_b -= 1\n break\n else :\n K -= B[i_b]\n \n count = (i_a+1) + (i_b+1) \n \n \n \n\n for i in range(i_a,-1,-1): \n K += A[i]\n for j in range(i_b,len(B)):\n if K < B[i_b]:\n i_b -= 1\n else :\n K -= B[i_b]\n count = max(count,((i)+(i_b+1)))\n print(count)', 'def get_sum_arr(arr):\n sum_arr = [0]\n N = len(arr)\n for i in range(1,N+1):\n sum_arr.append(sum_arr[i-1] + arr[i-1])\n return sum_arr\ndef get_max_book_num(A,B,K):\n A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)\n count,i,j = 0,0,0\n for i in range(0,len(A_sum_arr)):\n if K < A_sum_arr[i]:\n break\n else:\n K_temp = K - A_sum_arr[i]\n for j in range(len(B_sum_arr)):\n if B_sum_arr[j] > K_temp:\n break\n else:\n K_temp -= B_sum_arr[j]\n count = max(count,(i+j))\n return count\n\nif __name__ == "__main__":\n N,M,K = list(map(int,input().split()))\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)\n print(get_max_book_num(A,B,K))\n \n', 'if __name__ == "__main__":\n N,M,K = list(map(int,input().split()))\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n count,i_a,i_b = 0,0,0\n # ADD A item\n for i_a in range(len(A)):\n if K < A[i_a]:\n i_a -= 1\n break\n else:\n K -= A[i_a]\n # replace B item\n for i_b in range(len(B)):\n if K < B[i_b] :\n i_b -= 1\n break\n else :\n K -= B[i_b]\n \n count = (i_a+1) + (i_b+1) \n \n \n \n print("{}+{}={}".format(i_a,i_b,count))\n for i in range(i_a,-1,-1): \n K += A[i] \n\n j = 0\n for j in range(i_b+1,len(B)):\n if K < B[j]:\n j -= 1\n else :\n K -= B[j]\n i_b = j + 1\n \n \n count = max(count,(i+i_b))\n print(count)', '\nif __name__=="__main__":\n N,M,K = map(int,input().split())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n A_sum_arr,B_sum_arr = [0],[0]\n for i in range(len(A)):\n A_sum_arr.append(A[i]+A_sum_arr[i])\n for i in range(len(B)):\n B_sum_arr.append(B[i]+B_sum_arr[i])\n count = 0\n j = len(B_sum_arr) - 1\n for i,A_sum in enumerate(A_sum_arr):\n if A_sum > K:\n break\n else:\n b_val = K - A_sum\n while b_val < B_sum_arr[j]:\n j -= 1\n count = max(count,(i+j))\n print(count)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s479278094', 's491457441', 's669705282', 's719569315', 's721001930', 's967510968', 's852433423'] | [188300.0, 40508.0, 41164.0, 40628.0, 69784.0, 40464.0, 47540.0] | [1510.0, 326.0, 2206.0, 312.0, 2207.0, 2206.0, 275.0] | [912, 699, 1201, 1005, 867, 1160, 601] |
p02623 | u212786022 | 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\ndef Cum(X):\n temp = 0\n Cum = [0]*len(X)\n for i in range(len(X)):\n temp += X[i]\n Cum[i] += temp\n return Cum\n\na = Cum(A)\na.insert(0,0)\nb = Cum(B)\nb.insert(0,0)\n\nna = 0\nfor i in range(N+1):\n if i == N and a[i]<=K:\n na = N\n elif a[i]<=K and a[i+1]>K:\n na = i\n\nans = na\ntemp = K-a[na]\nnb = 0\nfor i in range(na,-1,-1):\n for j in range(nb,M+1):\n if j == M and b[i] <= temp:\n nb = M\n elif b[j]<=temp and b[j+1]>temp:\n nb = j\n ans = max(ans,i+nb)\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\ndef Cum(X):\n temp = 0\n Cum = [0]*len(X)\n for i in range(len(X)):\n temp += X[i]\n Cum[i] += temp\n return Cum\n\na = Cum(A)\na.insert(0,0)\nb = Cum(B)\nb.insert(0,0)\n\nna = 0\nfor i in range(N+1):\n if i == N and a[i]<=K:\n na = N\n elif a[i]<=K and a[i+1]>K:\n na = i\n\nans = na\n\nnb = 0\nfor i in range(na,-1,-1):\n temp = K-a[i]\n for j in range(nb,M+1):\n if j == M and b[j] <= temp:\n nb = M\n ans = max(ans,i+nb)\n elif b[j]<=temp and b[j+1]>temp:\n nb = j\n ans = max(ans,i+nb)\n break\n \nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s950246409', 's600932002'] | [50476.0, 47356.0] | [2207.0, 392.0] | [647, 714] |
p02623 | u216015528 | 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 dfs(a, b, k):\n nonlocal cnt\n seen[a][b] = True\n na = a + 1\n nb = b + 1\n if na <= N and seen[na][b] is False and k >= book_a[na]:\n k -= book_a[na]\n cnt = max(cnt, na + b)\n dfs(na, b, k)\n if nb <= M and seen[a][nb] is False and k >= book_b[nb]:\n k -= book_b[nb]\n cnt = max(cnt, a + nb)\n dfs(a, nb, k)\n \nN, M, k = map(int, input().split())\nbook_a = [int(x) for x in input().split()]\nbook_b = [int(x) for x in input().split()]\nbook_a.insert(0, 0)\nbook_b.insert(0, 0)\ncnt = 0\nseen = [[False] * (M + 1) for _ in range(N + 1)]\ndfs(0, 0, k)\nprint(cnt)', 'def resolve():\n N, M, K = map(int, input().split())\n A = [int(x) for x in input().split()]\n B = [int(x) for x in input().split()]\n\n \n a, b = [0], [0]\n for i in range(N):\n a.append(a[i] + A[i])\n for i in range(M):\n b.append(b[i] + B[i])\n\n \n ans, j = 0, 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 print(ans)\n\n\n\nif __name__ == "__main__":\n resolve()'] | ['Runtime Error', 'Accepted'] | ['s930836849', 's774431332'] | [9084.0, 47424.0] | [26.0, 228.0] | [614, 668] |
p02623 | u219226973 | 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 -*-\na = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nN = a[0]\nM = a[1]\nK = a[2]\n\ncount = 0 \ncount_time = 0 \n\nif K<A[0] and K<B[0]:\n print(count)\n \nelse:\n while K >= count_time:\n if len(A)!=0 and len(B)!=0:\n if A[0] >= B[0]:\n count_time += B[0]\n count += 1\n B.pop(0)\n print(count_time)\n continue\n\n elif A[0] < B[0]:\n count += 1\n count_time += A[0]\n A.pop(0)\n print(count_time)\n continue\n\n elif len(A)==0 and len(B)!=0:\n count += 1\n count_time += B[0]\n B.pop(0)\n print(count_time)\n continue\n\n elif len(B)==0 and len(A)!=0:\n count += 1\n count_time += A[0]\n A.pop(0)\n print(count_time)\n continue\n\n else:\n count += 1\n print(count_time)\n break\n \n print(count-1)\n', '# -*- coding: utf-8 -*-\na = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nN = a[0]\nM = a[1]\nK = a[2]\n\ncount = 0 \ncount_time = 0 \n\nif K<A[0] or K<B[0]:\n pass\n \nelse:\n while K > count_time:\n if len(A)!=0 and len(B)!=0:\n if A[0] >= B[0]:\n count_time += B[0]\n count += 1\n B.pop(0)\n\n if A[0] < B[0]:\n count += 1\n count_time += A[0]\n A.pop(0)\n\n elif len(A)==0 and len(B)!=0:\n count += 1\n count_time += B[0]\n B.pop(0)\n\n elif len(B)==0 and len(A)!=0:\n count += 1\n count_time += A[0]\n A.pop(0)\n\n else:\n count += 1\n break\n\nprint(count)\n', '# -*- coding: utf-8 -*-\na = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nN = a[0]\nM = a[1]\nK = a[2]\n\ncount = 0 \ncount_time = 0 \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])\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', '# -*- coding: utf-8 -*-\na = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nN = a[0]\nM = a[1]\nK = a[2]\n\ncount = 0 \ncount_time = 0 \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])\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'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s197297140', 's648954096', 's702771450', 's754545007'] | [41632.0, 42288.0, 47316.0, 47176.0] | [2206.0, 2206.0, 252.0, 285.0] | [1145, 869, 488, 488] |
p02623 | u221061152 | 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()))\n\namax = 0\ntime = 0\nfor a in A:\n if time + a > k: break\n time += a\n amax += 1\nbmax,time = 0,0\nfor b in B:\n if time + b > k: break\n time += b\n bmax += 1\nif amax == 0:\n print(bmax)\n exit()\nif bmax == 0:\n print(amax)\n exit()\nv = max(amax,bmax)\nans = v\n#print(amax,bmax)\nfor i in range(v+1,k+1):\n ok = False\n for j in range(i+1):\n if j>n or i-j > m: continue\n t = sum(A[:i])+sum(B[:(i-j)])\n if t <= k:\n ans = i\n ok = True\n break\n if ok == False:\n print(ans)\n exit()\nprint(ans)', 'from collections import deque\nn,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, j = 0,m\nfor i in range(N+1):\n if a[i]>k: break\n while b[j] > k-a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)', 'from itertools import accumulate\nfrom bisect import bisect\nn,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nA=list(accumulate(A,initial=0))\nB=list(map(int,input().split()))\nB=list(accumulate(B))\n\nans = 0\nfor i,a in enumerate(A):\n if a > k: break\n ans = max(ans,i + bisect(B,k-a))\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s411315391', 's726304172', 's043206573'] | [40780.0, 49496.0, 45332.0] | [2206.0, 204.0, 257.0] | [645, 344, 307] |
p02623 | u224554402 | 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 = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\ncount = 0\nfor i in range(n + m):\n print(k)\n if a_list[0] >= b_list[0] and len(a_list) >= 1:\n k -= a_list.pop(0)\n else:\n k -= b_list.pop(0)\n \n if k > 0:\n count += 1\n else:\n break\n \nprint(count+1)', 'n,m,k = list(map(int, input().split()))\na_list = np.array(input().split()).astype(int)\nb_list = np.array(input().split()).astype(int)\nans_list=[]\nfor i in range(n):\n for l in range(m):\n if sum(a_list[:i]) + sum(b_list[:l]) <= k:\n ans_list.append(i+l)\n \nans_list.sort()\nprint(ans_list[-1])', 'n, m,k = list(map(int, input().split()))\na_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\ncount = 0\nfor i in range(n + m):\n #print(k)\n if len(a_list) >= 1 and len(b_list) >= 1:\n if a_list[0] >= b_list[0]: \n k -= a_list.pop(0)\n elif len(a_list) == 0:\n k -= b_list.pop(0)\n else:\n k -= a_list.pop(0)\n \n if k > 0:\n count += 1\n else:\n break\nif count == n+m:\n print(count)\nelse:\n print(count+1)', 'import numpy as np\nparam_list = np.array(input().split()).astype(int)\na_list = np.array(input().split()).astype(int)\nb_list = np.array(input().split()).astype(int)\nans=0\nfor i in range(param_list[0]):\n for l in range(param_list[1]):\n a = sum(a_list[:i]) + sum(b_list[:l])\n b= 0\n if a <= param_list[2]:\n if b <= i+l:\n b = i+l\n \nprint(b)', 'import numpy as np\nparam_list = np.array(input().split()).astype(int)\na_list = np.array(input().split()).astype(int)\nb_list = np.array(input().split()).astype(int)\nans=0\nfor i in range(param_list[0]+1):\n for l in range(param_list[1]+1):\n a = sum(a_list[:i]) + sum(b_list[:l])\n b= 0\n if a <= param_list[2]:\n if b <= i+l:\n b = i+l\n \nprint(b)', 'import numpy as np\nn,m,k = list(map(int, input().split()))\na_list = np.array(input().split()).astype(int)\nb_list = np.array(input().split()).astype(int)\na_sum =[0]\nb_sum=[0]\nfor i in range(n):\n a_sum.append(a_sum[-1]+ a_list[i])\nfor i in range(m):\n b_sum.append(b_sum[-1] + b_list[i])\n#print(a_sum, b_sum)\ntotal = 0\n\nfor i in range(n+1):\n num = 0\n if a_sum[i] > k:\n break\n while (k - a_sum[i]) >= b_sum[num]:\n num +=1\n #print(i, num)\n if num == m:\n break\n total = max(i+num, total)\n \n \nprint(total)', 'import numpy as np\nn,m,k = list(map(int, input().split()))\na_list = np.array(input().split()).astype(int)\nb_list = np.array(input().split()).astype(int)\na_sum =[0]\nb_sum=[0]\nfor i in range(n):\n a_sum.append(a_sum[-1]+ a_list[i])\nfor i in range(m):\n b_sum.append(b_sum[-1] + b_list[i])\n#print(a_sum, b_sum)\ntotal = 0\nnum = m\n\nfor i in range(n+1):\n \n if a_sum[i] > k:\n break\n while (k - a_sum[i]) < b_sum[num]:\n num -=1\n #print(i, num)\n if num == -1:\n break\n total = max(i+num, total)\n \n \nprint(total)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s078354462', 's130089106', 's361075941', 's368153709', 's633018917', 's720541219', 's338642213'] | [40696.0, 9000.0, 40432.0, 60300.0, 60556.0, 60716.0, 60444.0] | [2206.0, 25.0, 2206.0, 2207.0, 2206.0, 2207.0, 630.0] | [374, 320, 498, 397, 401, 561, 562] |
p02623 | u227085629 | 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()))\nna = []\nc = 0\nfor booka in a:\n c += booka\n na.append(c)\nnb = []\nd = 0\nfor bookb in b:\n d += bookb\n nb.append(d)\nmaxa = 0\nfor i in range(n):\n for j in range(maxa-i,m):\n if na[i] + nb[j] <= k:\n maxa = max(maxa,i+j+2)\nprint(maxa)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nna,nb = [0],[0]\nfor i in range(n):\n na.append(na[i]+a[i])\nfor j in range(m):\n nb.append(nb[j]+b[j])\nans = 0\nl = m\nfor i in range(n+1):\n if na[i] > k:\n break\n while nb[l] > k - na[i]:\n l -= 1\n ans = max(ans,i+l)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s787610152', 's908183459'] | [47468.0, 47480.0] | [2207.0, 292.0] | [342, 335] |
p02623 | u228303592 | 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())\narr0 = list(map(int,input().split()))\narr1 = list(map(int,input().split()))\nacc0 = []\n\nfor i in range(n):\n acc0.append(acc0[-1] + arr0[i])\nacc1 = []\nfor i in range(m):\n acc1.append(acc1[-1] + arr1[i])\nans = 0\nj = m\nfor i in range(n+1):\n if acc0[i] > k:\n break\n while acc1[j] > k - acc0[i] and j > 0:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n', 'n,m,k = map(int,input().split())\narr0 = list(map(int,input().split()))\narr1 = list(map(int,input().split()))\nacc0 = [0]\n\nfor i in range(n):\n acc0.append(acc0[-1] + arr0[i])\nacc1 = [0]\nfor i in range(m):\n acc1.append(acc1[-1] + arr1[i])\nans = 0\nj = m\nfor i in range(n+1):\n if acc0[i] > k:\n break\n while acc1[j] > k - acc0[i] and j > 0:\n j -= 1\n ans = max(i + j)\n\nprint(ans)\n', 'n,m,k = map(int,input().split())\narr0 = list(map(int,input().split()))\narr1 = list(map(int,input().split()))\nacc0 = [0]\n\nfor i in range(n):\n acc0.append(acc0[-1] + arr0[i])\nacc1 = [0]\nfor i in range(m):\n acc1.append(acc1[-1] + arr1[i])\nans = 0\nj = m\nfor i in range(n+1):\n if acc0[i] > k:\n break\n while acc1[j] > k - acc0[i] and j > 0:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s317821028', 's691143117', 's711670549'] | [40616.0, 47360.0, 47560.0] | [107.0, 220.0, 290.0] | [387, 384, 388] |
p02623 | u231570044 | 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 random\nimport bisect\nfrom collections import deque\n\nx = input().split()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nn, m, time = int(x[0]), int(x[1]), int(x[2])\n\n#n, m = 100000, 100000\n#time = 100000000\n#a = list(random.choices(range(10000), k=n))\n#b = list(random.choices(range(10000), k=m))\n\na_sum, b_sum = cumsum(a), cumsum(b)\n\na_pos = bisect.bisect_left(a_sum, time)\nb_pos = bisect.bisect_left(b_sum, time)\nread = 0\nfor i in range(a_pos):\n bpos = bisect.bisect_left(b_sum, time-a_sum[i]+.1)\n read = max(read, i+bpos+1)\n\nprint (read)\n\ndef cumsum(a):\n tmp = 0\n ret = []\n for i in range(len(a)):\n tmp += a[i]\n ret.append(tmp)\n return ret\n', 'import sys\nimport random\nimport bisect\nfrom collections import deque\n\ndef cumsum(a):\n tmp = 0\n ret = []\n for i in range(len(a)):\n tmp += a[i]\n ret.append(tmp)\n return ret\n\n#x = input().split()\n#a = list(map(int, input().split()))\n#b = list(map(int, input().split()))\n#n, m, time = int(x[0]), int(x[1]), int(x[2])\n\n#n, m = 100000, 100000\n#time = 100000000\n#a = list(random.choices(range(10000), k=n))\n#b = list(random.choices(range(10000), k=m))\n\na_sum, b_sum = cumsum(a), cumsum(b)\n\nans, j = 0, M\nfor i in range(N + 1):\n if a_sum[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\nimport random\nimport bisect\nfrom collections import deque\n\ndef cumsum(a):\n tmp = 0\n ret = []\n for i in range(len(a)):\n tmp += a[i]\n ret.append(tmp)\n return ret\n\nx = input().split()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nn, m, k = int(x[0]), int(x[1]), int(x[2])\n\n#n, m = 100000, 100000\n#time = 100000000\n#a = list(random.choices(range(10000), k=n))\n#b = list(random.choices(range(10000), k=m))\n\na_sum, b_sum = cumsum(a), cumsum(b)\n\nans, j = 0, m-1\nfor i in range(n):\n if a_sum[i] > k:\n break\n while b_sum[j] > k-a_sum[i]:\n print(j)\n j -= 1\n ans = max(ans, i + j + 2)\n\nprint (ans)\n', 'import sys\nimport random\nimport bisect\nfrom collections import deque\n\ndef cumsum(a):\n tmp = 0\n ret = []\n for i in range(len(a)):\n tmp += a[i]\n ret.append(tmp)\n return ret\n\nx = input().split()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nn, m, k = int(x[0]), int(x[1]), int(x[2])\n\n#n, m = 100000, 100000\n#time = 100000000\n#a = list(random.choices(range(10000), k=n))\n#b = list(random.choices(range(10000), k=m))\n\na_sum, b_sum = cumsum(a), cumsum(b)\n\nans, j = 0, m\nfor i in range(n + 1):\n if a_sum[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\nimport random\nimport bisect\nfrom collections import deque\n\ndef cumsum(a):\n tmp = 0\n ret = []\n for i in range(len(a)):\n tmp += a[i]\n ret.append(tmp)\n return ret\n\nx = input().split()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nn, m, time = int(x[0]), int(x[1]), int(x[2])\n\n#n, m = 100000, 100000\n#time = 100000000\n#a = list(random.choices(range(10000), k=n))\n#b = list(random.choices(range(10000), k=m))\n\na_sum, b_sum = cumsum(a), cumsum(b)\n\nans, j = 0, m\nfor i in range(n + 1):\n if a_sum[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()))\n\na, b = [0], [0]\nfor i in range(N): a.append(a[i] + A[i])\nfor i in range(M): 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'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s017878956', 's242839144', 's316286376', 's406479358', 's640629902', 's983700739'] | [40824.0, 9880.0, 48524.0, 48276.0, 48180.0, 47376.0] | [106.0, 27.0, 417.0, 180.0, 179.0, 287.0] | [717, 666, 680, 659, 662, 356] |
p02623 | u234454594 | 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())\nal=[int(i) for i in input().split()]\nbl=[int(i) for i in input().split()]\nfor i in range(1,n):\n al[i]+=al[i-1]\nfor i in range(1,m):\n bl[i]+=bl[i-1]\nans=0\nj=m-1\nfor i in in range(n):\n if al[i]>k:\n break\n while bl[j]>al[i]-k:\n j-=1\n ans=max(ans,i+j)\nprint(ans)\n', 'n,m,k=map(int,input().split())\nal=[int(i) for i in input().split()]\nbl=[int(i) for i in input().split()]\nfor i in range(1,n):\n al[i]+=al[i-1]\nfor i in range(1,m):\n bl[i]+=bl[i-1]\nans=0\nj=m\nfor i in in range(n):\n if al[i]>k:\n break\n while bl[j]>al[i]-k:\n j-=1\n ans=max(ans,i+j)\nprint(ans)\n', 'n,m,k=map(int,input().split())\nal=[int(i) for i in input().split()]\nbl=[int(i) for i in input().split()]\naa,bb=[0],[0]\nfor i in range(n):\n aa.append(aa[i]+al[i])\nfor i in range(m):\n bb.append(bb[i]+bl[i])\nans=0\nj=m\nfor i in range(n+1):\n if aa[i]>k:\n break\n while bb[j]>k-aa[i]:\n j-=1\n ans=max(ans,i+j)\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s817669991', 's856723158', 's534500857'] | [9056.0, 9060.0, 47648.0] | [26.0, 24.0, 301.0] | [319, 317, 342] |
p02623 | u235210692 | 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\n\n\nimport math\nimport sys\n\nsys.setrecursionlimit(10 ** 9)\n\n\ndef binary_research(start, end,function):\n if start == end:\n return start\n middle = math.ceil((start + end) / 2)\n if function(middle, k, a_sum, b_sum):\n start = middle\n else:\n end = middle - 1\n return binary_research(start, end, function)\n\n\n# ==================================================-\n\nn, m, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\na_sum = [0]\nb_sum = [0]\nfor book in a:\n a_sum.append(a_sum[-1] + book)\nfor book in b:\n b_sum.append(b_sum[-1] + book)\n\n\ndef can_read(num, k, a_sum, b_sum):\n min_read_time = 1000000000000\n sentou=\n for i in range(max(0, num - m), min(num+1,n+1)):\n a_num = i\n b_num = num - i\n min_read_time = min(min_read_time, a_sum[a_num] + b_sum[b_num])\n if min_read_time <= k:\n return True\n return False\n\n\nstart = 0\nend = n + m\n\nprint(binary_research(start, end, can_read))', '# ==================================================-\n\n\n\nimport math\nimport sys\n\nsys.setrecursionlimit(10 ** 9)\n\n\ndef binary_research(start, end,function):\n if start == end:\n return start\n middle = math.ceil((start + end) / 2)\n if function(middle, k, a_sum, b_sum):\n start = middle\n else:\n end = middle - 1\n return binary_research(start, end, function)\n\n\n# ==================================================-\n\nn, m, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\na_sum = [0]\nb_sum = [0]\nfor book in a:\n a_sum.append(a_sum[-1] + book)\nfor book in b:\n b_sum.append(b_sum[-1] + book)\n\n\ndef can_read(num, k, a_sum, b_sum):\n min_read_time = 1000000000000\n for i in range(max(0, num - m), min(num+1,n+1)):\n a_num = i\n b_num = num - i\n min_read_time = min(min_read_time, a_sum[a_num] + b_sum[b_num])\n if min_read_time <= k:\n return True\n return False\n\n\nstart = 0\nend = n + m\n\nprint(binary_research(start, end, can_read))'] | ['Runtime Error', 'Accepted'] | ['s569072517', 's231828057'] | [9012.0, 47416.0] | [24.0, 909.0] | [1276, 1264] |
p02623 | u238084414 | 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\nt = sum(A)\ni = N\nans = 0\n\nfor j in range(M + 1):\n while i > 0 and t > K:\n i -= 1\n t -= A[i] \n print(t)\n if t > K:\n break\n ans = max(ans, i + j)\n if j == M:\n break\n t += B[j]\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nt = sum(A)\ni = N\nans = 0\n\nfor j in range(M + 1):\n while i > 0 and t > K:\n i -= 1\n t -= A[i]\n if t > K:\n break\n ans = max(ans, i + j)\n if j == M:\n break\n t += B[j]\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s691142885', 's380098294'] | [40580.0, 40352.0] | [296.0, 241.0] | [311, 299] |
p02623 | u238438917 | 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\na,b=[0],[0]\nfor i in range(n):\n a.apppend(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 \n ans=max(ans,i+j)\n \nprint(ans)\n \n\n ', 'n=list(map(int,input().split()))\nm=list(map(int,input().split()))\nt=list(map(int,input().split()))\n\nli=m+t\ni=0\ncount=0\n\nwhile i< len(li):\n if li[i] + count <= n[2]:\n count +=1\n i+=1\n\n\n\nprint(count)\n\n\n', 'n,m,k=list(map(int,input().split()))\n\na=list(map(int,input().split()))\n\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\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\n ans =max(ans,i+j)\n\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s423608983', 's953553294', 's793303868'] | [8856.0, 40512.0, 47344.0] | [26.0, 233.0, 288.0] | [349, 205, 350] |
p02623 | u243312682 | 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 main():\n n, m, k = map(int, input().split())\n a = [int(x) for x in input().split()]\n b = [int(x) for x in input().split()]\n\n maxv = 0\n acum = [0] * (n + 1)\n bcum = [0] * (m + 1)\n for i in range(n):\n acum[i + 1] = acum[i] + a[i]\n for i in range(m):\n bcum[i + 1] = bcum[i] + b[i]\n\n for i in range(n + 1):\n if acum[i] > k:\n continue\n maxv = max(maxv, i + bisect_right(bcum, k - acum[i]) - 1)\n print(maxv)\n\nif __name__ == '__main__':\n main()", "from bisect import bisect_right\n \ndef main():\n n, m, k = map(int, input().split())\n a = [int(x) for x in input().split()]\n b = [int(x) for x in input().split()]\n \n maxv = 0\n acum = [0] * (n + 1)\n bcum = [0] * (m + 1)\n for i in range(n):\n acum[i + 1] = acum[i] + a[i]\n for i in range(m):\n bcum[i + 1] = bcum[i] + b[i]\n \n for i in range(n + 1):\n if acum[i] > k:\n break\n maxv = max(maxv, i + bisect_right(bcum, k - acum[i]) - 1)\n print(maxv)\n \nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s328517500', 's485721782'] | [47572.0, 47504.0] | [175.0, 277.0] | [513, 547] |
p02623 | u247830763 | 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())\nlsa = list(map(int,input().split()))\nlsb = list(map(int,input().split()))\nimport numpy \nla = [0]+[e for e in numpy.cumsum(numpy.array(lsa)) if e <= k]\nlb = [0]+[e for e in numpy.cumsum(numpy.array(lsb)) if e <= k]\nprint(la)\nprint(lb)\nmx = 0\nfor i in range(len(la)):\n for j in range(len(lb)):\n a = la[i]+lb[j]\n if a <= k:\n if i+j > mx:\n mx = i+j\nprint(mx)', 'a = list(map(int,input().split()))\nb = list(map(int,input().split()))\nla = [0]\nlb = [0]\nmx = 0\nfor i in range(n): \n la.append(la[i]+a[i])\nfor j in range(m):\n lb.append(lb[j]+b[j])\nfor l in range(len(la)):\n if la[l] > k:\n break\n cnt = l\n q = 0\n p = 0\n while la[l] + p <= k:\n q += 1\n if q == len(lb):\n cnt += len(lb)-1\n break\n p = lb[q] \n if cnt == l:\n cnt += q - 1\n if cnt > mx:\n mx = cnt\nprint(mx)\n', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nla = [0]\nlb = [0]\nmx = 0\nfor i in range(n): \n if la[i] + a[i] > k:\n break\n la.append(la[i]+a[i])\nfor j in range(m):\n if lb[j] + b[j] > k:\n break\n lb.append(lb[j]+b[j])\nnow = len(lb)-1\nfor l in range(len(la)):\n cnt = l\n q = now\n while la[l] + lb[q] > k:\n q -= 1\n now = q\n cnt += q\n if cnt > mx:\n mx = cnt\nprint(mx)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s190962507', 's586365663', 's738546757'] | [62868.0, 32748.0, 40564.0] | [2213.0, 70.0, 313.0] | [430, 489, 474] |
p02623 | u248364740 | 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 python\n# -*- coding: utf-8 -*-\n\nN, M, K = map(int, input().split())\nresult = 0 # max\na_time = list(map(int, input().split()))\nb_time = list(map(int, input().split()))\n\nsum = 0\n\na_num = 0\nfor i in range(N):\n sum += a_time[i]\n a_num += 1\n if sum > K:\n sum -= a_time[i]\n a_num -= 1\n break\ni = a_num\nwhile i >= 0:\n sum -= a_time[i]\n for j in range(M):\n sum += b_time[j]\n if sum > K:\n sum -= b_time[j]\n break\n print('result={} i={} j={}'.format(result, i, j))\n if result < i + j:\n result = i + j\n i -= 1\n\nprint(result)\n", '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nN, M, K = map(int, input().split())\nresult = 0 # max\na_time = list(map(int, input().split()))\nb_time = list(map(int, input().split()))\n\nsum = 0\n\na_num = 0\nfor i in range(N):\n sum += a_time[i]\n a_num += 1\n if sum > K:\n sum -= a_time[i]\n a_num -= 1\n break\ni = a_num\nj = 0\nwhile i >= 0:\n while sum < K and j < M:\n sum += b_time[j]\n j += 1\n if sum > K:\n j -= 1\n sum -= b_time[j]\n if result < i + j:\n result = i + j\n i -= 1\n sum -= a_time[i]\n\nprint(result)\n'] | ['Runtime Error', 'Accepted'] | ['s696807246', 's361552442'] | [42336.0, 42312.0] | [476.0, 295.0] | [617, 579] |
p02623 | u248967559 | 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 = list(map(int, input().split(" ")))\nA = list(map(int, input().split(" ")))\nB = list(map(int, input().split(" ")))\n\nasum = [0]\nfor a in A:\n asum.append(asum[-1] + a)\n\nbsum = [0]\nfor b in B:\n bsum.append(bsum[-1] + b)\n\nans = 0\nfor i, a in enumerate(asum):\n btime = K - a\n if btime > 0:\n break\n bindex = bisect.bisect_right(bsum, btime)\n ans = max(ans, i + (bindex-1))\n\nprint(ans)\n', 'import bisect\n\nN, M, K = list(map(int, input().split(" ")))\nA = list(map(int, input().split(" ")))\nB = list(map(int, input().split(" ")))\n\nasum = [0]\nfor a in A:\n asum.append(asum[-1] + a)\n\nbsum = [0]\nfor b in B:\n bsum.append(bsum[-1] + b)\n\nans = 0\nfor i, a in enumerate(asum):\n btime = K - a\n if btime < 0:\n break\n bindex = bisect.bisect_right(bsum, btime)\n ans = max(ans, i + (bindex-1))\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s797124056', 's881590981'] | [47372.0, 47608.0] | [184.0, 315.0] | [427, 427] |
p02623 | u252405453 | 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 abc172c_tsundoku():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n A = [0] * (n + 1)\n B = [0] * (m + 1)\n\n for i in range(1, n + 1):\n A[i] = A[i - 1] + a[i - 1]\n if A[i] > k:\n n = i - 1\n break\n for i in range(1, m + 1):\n B[i] = B[i - 1] + b[i - 1]\n if B[i] > k:\n m = i - 1\n break\n ans = 0\n for i in range(0, n + 1):\n j = max(ans - i, 0)\n if j > m or A[i] + B[j] > k: continue\n while j < m:\n if A[i] + B[j] > k:\n j -= 1\n break\n j += 1\n ans = max(i + j, ans)\n print(ans)\n\n\nabc172c_tsundoku()', 'def abc172c_tsundoku():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n A = [0] * (n + 1)\n B = [0] * (m + 1)\n\n for i in range(1, n + 1):\n A[i] = A[i - 1] + a[i - 1]\n if A[i] > k:\n n = i - 1\n break\n for i in range(1, m + 1):\n B[i] = B[i - 1] + b[i - 1]\n if B[i] > k:\n m = i - 1\n break\n ans = 0\n for i in range(0, n+1):\n j = max(ans - i, 0)\n if j > m: continue\n while j < m:\n if A[i] + B[j] > k:\n j -= 1\n break\n j += 1\n ans = max(i + j, ans)\n print(ans)\n\n\nabc172c_tsundoku()', 'def abc172c_tsundoku():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n A = [0] * (n + 1)\n B = [0] * (m + 1)\n\n for i in range(1, n + 1):\n A[i] = A[i - 1] + a[i - 1]\n if A[i] > k:\n n = i - 1\n break\n for i in range(1, m + 1):\n B[i] = B[i - 1] + b[i - 1]\n if B[i] > k:\n m = i - 1\n break\n ans = 0\n for i in range(0, n + 1):\n j = max(ans - i, 0)\n if j > m or A[i] + B[j] > k: continue\n while j <= m:\n if A[i] + B[j] > k:\n j -= 1\n break\n j += 1\n j = min(m,j)\n ans = max(i + j, ans)\n print(ans)\n\n\nabc172c_tsundoku()'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s690905456', 's924465141', 's081036359'] | [42492.0, 41232.0, 42696.0] | [292.0, 278.0, 327.0] | [739, 718, 761] |
p02623 | u252828980 | 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]\na = [0]+a\nb = [0]+b\n\nans = 0\nALL = 0\nfrom bisect import bisect\nfor i in range(n+1):\n ALL = a[i]\n if ALL > k:\n continue\n else:idx = bisect(b,k-ALL)\n #print(i,ALL,idx)\n ans = max(ans,i+idx-1)\nprint(ans)', 'from collections import deque\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\na = deque(a)\nb = deque(b)\n#print(a,b)\nnum = 0\ncnt = 0\n\nL = []\nwhile a and b:\n if a[0] <=b[0]:\n L.append(a[0])\n a.popleft()\n else:\n L.append(b[0])\n b.popleft()\nif a:\n for i in range(len(a)):\n L.append(a[i])\nif b:\n for i in range(len(b)):\n L.append(b[i])\n#print(L,a,b)\nfor i in range(len(L)):\n num +=L[i]\n #print(num)\n if num >k:\n print(i)\n elif num == k:\n print(i+1)\n exit()', 'a,b,k = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nfrom itertools import accumulate\n\nA = list(accumulate(A))\nB = list(accumulate(B))\nA = [0] + A\nB = [0] + B\n\nans = 0\nnum = b\nfor i in range(a+1):\n if A[i] > k:\n continue\n while True :\n if A[i] + B[num] > k:\n num -=1\n else:\n ans = max(ans,i+num)\n break\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s258728998', 's427113855', 's266673299'] | [8936.0, 40568.0, 40392.0] | [27.0, 937.0, 250.0] | [409, 593, 424] |
p02623 | u259190728 | 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=int(input())\nl=[0]*(n+1)\nfor i in range(1,n+1):\n\n for j in range(i,n+1,i):\n\n l[j]+=1\nc=0\nfor i in range(1,n+1):\n c+=i*l[i]\n\nprint(c)\n', 'n=int(input())\nl=[0 for i in range(n+1)]\nfor i in range(1,n+1):\n \n for j in range(i,n+1,i):\n \n l[j]+=1\nc=0\nfor i in range(1,n+1):\n c+=i*l[i]\n \nprint(c)', '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\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\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s203205104', 's763573503', 's368393447'] | [9188.0, 9196.0, 47348.0] | [31.0, 26.0, 282.0] | [148, 164, 318] |
p02623 | u260036763 | 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\nsum_a = 0\nfor i in range(-1, len(A)):\n if i == -1:\n sum_a = 0\n else:\n sum_a += A[i]\n if sum_a > K:\n break\n sum_b = 0\n for j in range(len(B)):\n sum_b += B[j]\n if sum_b > K - sum_a:\n ans = max(ans, i+1+j)\n print("i = {0}, j = {1}, i+j +1 = {2}".format(i, j, i+j+1))\n break\n if j == len(B)-1: \n ans = max(ans, i+j+2)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nans = 0\nsum_a = 0\nfor i in range(-1, len(A)):\n if i == -1:\n sum_a = 0\n else:\n sum_a += A[i]\n if sum_a > K:\n break\n sum_b = 0\n for j in range(len(B)):\n sum_b += B[j]\n if sum_b > K - sum_a:\n ans = max(ans, i+1+j)\n break\n if j == len(B)-1: \n ans = max(ans, i+j+2)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nans = 0\nsum_a = 0\nfor i in range(len(A)+1):\n if i == 0:\n sum_a = 0\n else:\n sum_a += A[i-1]\n if sum_a > K:\n break\n sum_b = 0\n for j in range(len(B)):\n sum_b += B[j]\n if sum_b > K - sum_a:\n ans = max(ans, i+j)\n break\n if j == len(B)-1:\n ans = max(ans, i+j+1)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nans = 0\nsum_a = 0\nfor i in range(len(A)+1):\n if i == 0:\n sum_a = 0\n else:\n sum_a += A[i-1]\n if sum_a > K:\n break\n sum_b = 0\n for j in range(len(B)):\n sum_b += B[j]\n if sum_b > K - sum_a:\n ans = max(ans, i+j)\n break\n if j == len(B)-1: \n ans = max(ans, i+j+1)\nprint(ans)', 'import bisect\nN, 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)\n\n\nfor i in range(1, N+1):\n a[i] = a[i-1] + A[i-1]\nfor j in range(1, M+1):\n b[j] = b[j-1] + B[j-1]\n\nans = 0\n# j = M\nfor i in range(N+1):\n# left = 0\n# right = j\n if K - a[i] < 0:\n break\n# while left < right:\n# mid = (left + right)//2\n# if b[mid] < K - a[i]:\n# left = mid + 1\n# elif b[mid] > K - a[i]:\n# right = mid - 1\n# if b[left] <= K - a[i]:\n# j = left\n# else:\n# j = left - 1\n j = bisect.bisect_right(b, K - a[i]) - 1\n ans = max(ans, i + j)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s285593573', 's715957831', 's847812258', 's999530601', 's738884412'] | [40440.0, 40444.0, 40420.0, 40560.0, 47432.0] | [120.0, 120.0, 119.0, 118.0, 357.0] | [620, 548, 477, 545, 727] |
p02623 | u262525101 | 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. | ['\nind_b = 0\nmax_b = 0\nfor i in range(1, N + 1):\n if cumsum_a[i] <= K:\n max_a = i\n else:\n break\n\nfor i in range(1, M + 1):\n if cumsum_b[i] <= K:\n max_b = i\n else:\n break\n\nfor i in range(max_a, -1, -1):\n for j in range(ind_b, max_b+1):\n if cumsum_b[j] + cumsum_a[i] <= K:\n # print("ok")\n num_book = max(i + j, num_book)\n ind_b = j\n else:\n break\nprint(num_book)', 'import numpy as np\n\nN, M, K = list(map(int, input().split()))\nA = list(map(int, [0] + input().split()))\nB = list(map(int, [0] + input().split()))\ncost = 0\ncumsum_a = np.cumsum(A)\ncumsum_b = np.cumsum(B)\n\nnum_book = 0\nmax_a = 0\nind_b = 0\nmax_b = 0\nfor i in range(1, N + 1):\n if cumsum_a[i] <= K:\n max_a = i\n else:\n break\n\nfor i in range(1, M + 1):\n if cumsum_b[i] <= K:\n max_b = i\n else:\n break\n\nfor i in range(max_a, -1, -1):\n for j in range(ind_b, max_b+1):\n if cumsum_b[j] + cumsum_a[i] <= K:\n # print("ok")\n num_book = max(i + j, num_book)\n ind_b = j\n else:\n break\nprint(num_book)\n'] | ['Runtime Error', 'Accepted'] | ['s752533803', 's340929958'] | [9064.0, 59564.0] | [29.0, 842.0] | [458, 685] |
p02623 | u262597910 | 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 = n\nB = 0\nif (a[0]>k):\n A = 0\nfor i in range(1,n):\n a[i] += a[i-1]\n if (a[i]>k):\n A = i\nfor i in range(1,m):\n b[i] += b[i-1]\nif (a[0]>k):\n A = 0\nans = A\nwhile True:\n if (A<0):\n break\n if (B>=m):\n break\n B += 1\n if (A==0):\n for i in range(m):\n if (b[i]>k):\n print(i)\n exit()\n print(len(b))\n exit()\n if (a[A-1]+b[B-1] >k):\n B -= 1\n A -= 1\n else:\n ans = max(ans,A+B)\nprint(ans)', 'n,m,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA = n\nB = 0\nfor i in range(1,n):\n a[i] += a[i-1]\n if (a[i]>k):\n A = i\n break\nfor i in range(1,m):\n b[i] += b[i-1]\nans = A\nif (a[0]>k):\n for i in range(m):\n if (b[i]>k):\n print(i)\n exit()\n print(len(b))\n exit()\na = [0] + a\nb = [0] + b\nwhile True:\n if (A<0):\n break\n if (B>=m):\n break\n B += 1\n \n if (a[A]+b[B] >k):\n B -= 1\n A -= 1\n else:\n ans = max(ans,A+B)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s835414855', 's501793776'] | [40404.0, 40628.0] | [360.0, 335.0] | [627, 622] |
p02623 | u265525892 | 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. | ['#include <bits/stdc++.h>\nusing namespace std;\n\nint main()\n{\n\tll n,m,k;\n\tcin>>n>>m>>k;\n\tll a[n+1];\n\tll b[m+1];\n\ta[0]=0;\n\tb[0]=0;\n\tfor(ll i=1;i<=n;i++)\n\t{\n\t\tcin>>a[i];\n\t\ta[i]+=a[i-1];\n\t}\n\tfor(ll i=1;i<=m;i++)\n\t{\n\t\tcin>>b[i];\n\t\tb[i]+=b[i-1];\n\t}\n\tll j=m;\n\tll ans=0;\n\tfor(ll i=1;i<=n;i++)\n\t{\n\t\tif(a[i]>k)break;\n\t\twhile(j>=0 && a[i]+b[j]>k)\n\t\t{\n\t\t\tj--;\n\t\t}\n\t\tif(j>=0)\n\t\tans=max(ans,i+j);\n\t}\n\tcout<<ans;\n\treturn 0;\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\ta.append(a[i] + A[i])\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)\n'] | ['Runtime Error', 'Accepted'] | ['s485587203', 's650848672'] | [8948.0, 47316.0] | [24.0, 303.0] | [429, 336] |
p02623 | u268318377 | 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 sys\nread = sys.stdin.buffer.read\n\n\nN, M, K = map(int, input().split())\nAB = np.array(read().split(), np.int32)\nA = [0] + np.cumsum(AB[:N]).tolist()\nB = [0] + np.cumsum(AB[N:]).tolist()\nassert (N == len(A) - 1) and (M == len(B) - 1)\n\nleft = 0\nfor i, b in enumerate(B):\n if b > K:\n left = i - 1\n break\n\nans = 0\nif A[-1] + B[-1] <= K:\n ans = N + M\nelse:\n for i in range(len(A)):\n if A[i] > K:\n break\n\n while A[i] + B[left] > K:\n left -= 1\n\n ans = max(ans, left + i)\n\nprint(ans)', 'import numpy as np\nimport sys\nread = sys.stdin.buffer.read\n\n\nN, M, K = map(int, input().split())\nAB = np.array(read().split(), np.int32)\nA = [0] + np.cumsum(AB[:N]).tolist()\nB = [0] + np.cumsum(AB[N:]).tolist()\nassert (N == len(A) - 1) and (M == len(B) - 1)\n\nleft = M\nfor i, b in enumerate(B):\n if b > K:\n left = i\n\nans = 0\nfor i in range(len(A)):\n if A[i] > K:\n break\n\n while A[i] + B[left] > K:\n left -= 1\n\n ans = max(ans, left + i)\n\nprint(ans)', 'import numpy as np\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n \n\nN, M, K = map(int, readline().split())\nAB = np.array(read().split(), np.int32)\nA = [0] + np.cumsum(AB[:N]).tolist()\nB = [0] + np.cumsum(AB[N:]).tolist()\nassert (N == len(A) - 1) and (M == len(B) - 1)\n \nans = 0\nleft = M\nfor i in range(len(A)):\n if A[i] > K:\n break\n \n while A[i] + B[left] > K:\n left -= 1\n \n ans = max(ans, left + i)\n\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s077680884', 's525629346', 's153571586'] | [53324.0, 53120.0, 53436.0] | [207.0, 208.0, 315.0] | [566, 479, 465] |
p02623 | u276975953 | 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\nstackA = [int(x) for x in input().split()]\nstackB = [int(x) for x in input().split()]\n\nindexB = 0\nindexA = 0\n\nbooks = 0\nmostBooks = 0\ntime = 0\n\nfor x in stackB:\n if time + x > K:\n indexB -= 1\n break\n\n else:\n time += x\n indexB += 1\n books += 1\n\nindexB -= 1\n\nmostBooks = books\n\nfor x in stackA:\n time += x\n books += 1\n\n while time > K and indexB >= 0:\n time -= stackB[indexB]\n indexB -= 1\n books -= 1\n\n if indexB < 0 and time > K:\n break\n\n mostBooks = max(mostBooks, books)\n\nprint(mostBooks)', 'N, M, K = [int(x) for x in input().split()]\n\nstackA = [int(x) for x in input().split()]\nstackB = [int(x) for x in input().split()]\n\nindexB = 0\nindexA = 0\n\nbooks = 0\nmostBooks = 0\ntime = 0\n\nfor x in stackB:\n if time + x > K:\n break\n\n else:\n time += x\n indexB += 1\n books += 1\n\nindexB -= 1\n\nmostBooks = books\n\nfor x in stackA:\n time += x\n books += 1\n\n while time > K and indexB >= 0:\n time -= stackB[indexB]\n indexB -= 1\n books -= 1\n\n if indexB < 0 and time > K:\n break\n\n mostBooks = max(mostBooks, books)\n\nprint(mostBooks)'] | ['Wrong Answer', 'Accepted'] | ['s600028234', 's057577636'] | [40548.0, 40556.0] | [303.0, 284.0] | [619, 599] |
p02623 | u283719735 | 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\nar = [0] * (N)\nbr = [0] * (M)\n\nar[0] = A[0]\nfor i, v in enumerate(A):\n ar[i+1] = ar[i] + v\n\nbr[0] = B[0]\nfor i, v in enumerate(B):\n br[i+1] = br[i] + v\n\nmax_read = 0\nj = M\nfor i in range(N+1):\n rest = K - ar[i]\n if rest <= 0:\n break\n while br[j] > K - ar[i]:\n j -= 1\n\n max_read = max(max_read, i+j)\n\nprint(max_read)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ncount = 0\nar = [0] * (N + 1)\nbr = [0] * (M + 1)\n\nfor i, v in enumerate(A):\n ar[i+1] = ar[i] + v\n\nfor i, v in enumerate(B):\n br[i+1] = br[i] + v\n\nmax_read = 0\nj = M\nfor i in range(N+1):\n if ar[i] > K:\n break\n while br[j] > K - ar[i]:\n j -= 1\n max_read = max(max_read, i+j)\n\nprint(max_read)\n'] | ['Runtime Error', 'Accepted'] | ['s560992256', 's935263156'] | [40548.0, 47408.0] | [167.0, 306.0] | [467, 427] |
p02623 | u284045566 | 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\nfrom itertools import accumulate\n\nN , M , K = map(int , input().split())\na = list(map(int , input().split()))\nb = list(map(int , input().split()))\na = list(accumulate(a))\nb = list(accumulate(b))\na.insert(0,0)\n\nans = 0\nfor i in range(N + 1):\n if a[i] > K:\n break\n ans = max(ans , bisect.bisect_right(b, K - a[i]))\nprint(ans)\n', 'import bisect\nfrom itertools import accumulate\n\nN , M , K = map(int , input().split())\na = list(map(int , input().split()))\nb = list(map(int , input().split()))\na = list(accumulate(a))\nb = list(accumulate(b))\na.insert(0,0)\n\nans = 0\nfor i in range(N + 1):\n if a[i] > K:\n break\n ans = max(ans , i + bisect.bisect_right(b, K - a[i]))\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s300164228', 's565905281'] | [41120.0, 41016.0] | [244.0, 265.0] | [351, 355] |
p02623 | u288430479 | 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_right\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nsum_a = list(accumulate(a))\nb = list(map(int,input().split()))\nsum_b = list(accumulate(b))\nma = 0\nprint(sum_a,sum_b)\nfor i in range(len(sum_a)):\n x = sum_a[i]\n if k<x:\n break\n k -= x\n index = bisect_right(sum_b,k)\n ma = max(i+1+index,ma)\n k += x\n # print(x,k,index,ma)\nprint(ma)\n ', 'from itertools import accumulate\nfrom bisect import bisect_right\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nsum_a = [0]+list(accumulate(a))\nb = list(map(int,input().split()))\nsum_b = list(accumulate(b))\nma = 0\n#print(sum_a,sum_b)\nfor i in range(len(sum_a)):\n x = sum_a[i]\n if k<x:\n index = bisect_right(sum_b,k)\n ma = max(index,ma)\n else:\n k -= x\n index = bisect_right(sum_b,k)\n ma = max(i+index,ma)\n k += x\n # print(x,k,index,ma)\nprint(ma)\n '] | ['Wrong Answer', 'Accepted'] | ['s194478949', 's058251473'] | [56312.0, 52224.0] | [321.0, 289.0] | [441, 513] |
p02623 | u290014241 | 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()))\nLA = [0]\nLB = [0]\nfor i in range(N):\n C=LA[i]+A[i]\n if C>K:\n N=i\n break\n else:\n LA.append(C)\nfor j in range(M):\n C=LB[j]+B[j]\n if C>K:\n M=j\n break\n else:\n LB.append(C)\nr=N\nfor i in range(N+1):\n u=0\n for j in range(r-N+i,M+1):\n if LA[N-i]+LB[j]>K:\n r=max(r,N-i+j-1) \n u=1\n break\n if u==0:\n r=N-i+M\n break\nprint(r)\n', 'N, M, K=map(int,input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nLA = [0]\nLB = [0]\nfor i in range(N):\n C=LA[i]+A[i]\n if C>K:\n N=i\n break\n else:\n LA.append(C)\nfor j in range(M):\n C=LB[j]+B[j]\n if C>K:\n M=j\n break\n else:\n LB.append(C)\nr=N\nfor i in range(N+1):\n u=0\n for j in range(r-N+i,M+1):\n if LA[N-i]+LB[j]>K:\n r=max(r,N-i+j-1) \n u=1\n break\n if u==0:\n r=max(r,N-i+M)\n break\nprint(r)\n'] | ['Wrong Answer', 'Accepted'] | ['s663394918', 's915677564'] | [42384.0, 42208.0] | [399.0, 380.0] | [616, 623] |
p02623 | u294703554 | 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 sys import stdin, stdout\ninput = stdin.readline\nprint = stdout.write\nn, m, k = map(int, input().split())\na, b = [0], [0]\na += list(map(int, input().split())),\nb += 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]\ni, j, z = 0, m, 0\nwhile i <= n and a[i] <= k:\n while b[j] > k - a[i]:\n j -= 1\n z = max(z, i + j)\n i += 1\nprint(str(z))', '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]\ni, j, z = 0, m, 0\nwhile i <= n and a[i] <= k:\n while b[j] > k - a[i]:\n j -= 1\n z = max(z, i + j)\n i += 1\nprint(str(z))'] | ['Runtime Error', 'Accepted'] | ['s341598883', 's634761600'] | [39992.0, 39880.0] | [111.0, 284.0] | [430, 348] |
p02623 | u296150111 | 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(n):\n\ta[i+1]+=a[i]\nfor i in range(m):\n\tb[i+1]+=b[i]\nprint(a,b)\nfrom bisect import bisect_right\nans=0\nfor i in range(n+1):\n\tif k-a[i]>0:\n\t\tr=bisect_right(b,k-a[i])\n\t\tans=max(r+i-1,ans)\n\telse:\n\t\tbreak\nprint(ans)', '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(n):\n\ta[i+1]+=a[i]\nfor i in range(m):\n\tb[i+1]+=b[i]\nfrom bisect import bisect_right\nans=0\nfor i in range(n+1):\n\tif k-a[i]>=0:\n\t\tr=bisect_right(b,k-a[i])\n\t\tans=max(r+i-1,ans)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s773669819', 's937650832'] | [40352.0, 39968.0] | [392.0, 325.0] | [328, 304] |
p02623 | u301624971 | 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\nimport sys\nimport math\nimport itertools\nimport collections\n\ndef solve(N,M,K,A,B):\n accumA = [0,A.pop(0)]\n accumB = [0,B.pop(0)]\n for a in A:\n accumA.append(accumA[-1] + a)\n for b in B:\n accumB.append(accumB[-1] + b)\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 return ans\n\ndef main():\n N,M,K = map(int,input().split())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n # solve()\n print(solve(N,M,K,A,B))\n\nif __name__ == "__main__":\n main()\n\n\n', '\n\nimport sys\nimport math\nimport itertools\nimport collections\n\ndef solve(N,M,K,A,B):\n accumA = [0,A.pop(0)]\n accumB = [0,B.pop(0)]\n for a in A:\n accumA.append(accumA[-1] + a)\n for b in B:\n accumB.append(accumB[-1] + b)\n ans = 0\n j = M\n for i in range(N + 1):\n if accumA[i] > K:\n break\n while accumB[j] > K - accumA[i]:\n j -= 1\n ans = max(ans,i + j)\n return ans\n\ndef main():\n N,M,K = map(int,input().split())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n # solve()\n print(solve(N,M,K,A,B))\n\nif __name__ == "__main__":\n main()\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s353498372', 's211815628'] | [47720.0, 47832.0] | [173.0, 221.0] | [637, 652] |
p02623 | u303058371 | 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): A[i] += A[i - 1]\nfor i in range(1, M): B[i] += B[i - 1]\nprint(A)\nprint(B)\nans, j = 0, M - 1\nfor i in range(N):\n if A[i] > K: break\n while B[j] > K - A[i]: j -= 1\n ans = max(ans, i + j + 2)\n j = M - 1\nprint(ans)\n', "N, M, K = map(int, input().split())\nA = list(map(int, ('0 ' + input()).split()))\nB = list(map(int, ('0 ' + input()).split()))\n\nfor i in range(1, N + 1): A[i] += A[i - 1]\nfor i in range(1, M + 1): B[i] += B[i - 1]\nans, j = 0, M\n\nfor i in range(N + 1):\n if A[i] > K: break\n while B[j] > K - A[i]: j -= 1\n ans = max(ans, i + j)\nprint(ans)\n"] | ['Runtime Error', 'Accepted'] | ['s250882534', 's959274919'] | [40676.0, 40132.0] | [2213.0, 286.0] | [353, 345] |
p02623 | u303344598 | 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())\nnlist = list(map(int,input().split()))\nmlist = list(map(int,input().split()))\nresult = 0\n\n\nmrest = sum(mlist)\n\nmcount = m\n\n\nfor ncount in range(0, len(nlist) + 1):\n \n \n while mrest > 0 and mcount > 0 and mrest > k:\n mcount -= 1\n mrest -= mlist[mcount - 1]\n \n result = max(result, ncount + mcount)\n \n mrest -= nlist[ncount]\n \n if mrest <= 0:\n break\nprint(result)\n', 'n,m,k = map(int,input().split())\nnlist = list(map(int,input().split()))\nmlist = list(map(int,input().split()))\nresult = 0\n\n\nmrest = k\n\n\nmcount = m\n\n\nmtime = sum(mlist)\n\n\nntime = 0\n\n\nfor ncount in range(len(nlist) + 1):\n \n if ncount > 0:\n mrest -= nlist[ncount - 1]\n ntime += nlist[ncount - 1]\n \n if ntime > k:\n break;\n \n \n while mcount > 0 and mtime > mrest:\n mcount -= 1\n mtime -= mlist[mcount]\n \n result = max(result, ncount + mcount)\n \n if ncount == n:\n break;\nprint(result)\n'] | ['Runtime Error', 'Accepted'] | ['s465442452', 's618191744'] | [40576.0, 40416.0] | [212.0, 277.0] | [1127, 1506] |
p02623 | u307516601 | 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**6)\n\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfrom collections import deque\n\na = deque(a)\nb = deque(b)\n\nans = 0\ntime = k\n\nwhile time >= 0:\n if a and b:\n tmp_a = time-a[0]\n tmp_b = time-b[0]\n if tmp_a >= 0 and tmp_b >= 0 and a[0] <= b[0]:\n time -= a[0]\n a.popleft()\n ans += 1\n elif tmp_a >= 0 and tmp_b >= 0 and b[0] < a[0]:\n time -= b[0]\n b.popleft()\n ans += 1\n elif tmp_a >= 0:\n time -= a[0]\n a.popleft()\n ans += 1\n elif tmp_b >= 0:\n time -= b[0]\n b.popleft()\n ans += 1\n else:\n break\n elif a:\n tmp_a = time-a[0]\n if tmp_a >= 0:\n time -= a[0]\n a.popleft()\n ans += 1\n else:\n break\n elif b:\n tmp_b = time-b[0]\n if tmp_b >= 0:\n time -= b[0]\n b.popleft()\n ans += 1\n else:\n break\n else:\n break\n print(a,b,ans)\n\nprint(ans)', 'import sys\nsys.setrecursionlimit(10**6)\n\nN, 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\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)'] | ['Runtime Error', 'Accepted'] | ['s019425237', 's763959893'] | [160040.0, 47268.0] | [3533.0, 303.0] | [1164, 507] |
p02623 | u307622233 | 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. | ['1 N, M, K = map(int, input().split())\n2 A = list(map(int, input().split()))\n3 B = list(map(int, input().split()))\n4\n5 a, b = [0], [0]\n6 for i in range(N):\n7 \ta.append(a[i] + A[i])\n8 for i in range(M):\n9 \tb.append(b[i] + B[i])\n10\n11 ans, j = 0, M\n12 for i in range(N + 1):\n13 \u3000\u3000if a[i] > K:\n14 \t\t\u3000break\n15 \u3000while b[j] > K - a[i]:\n16 \u3000\u3000j -= 1\n17 \u3000ans = max(ans, i + j)\n18 print(ans)\n', '1 N, M, K = map(int, input().split())\n2 A = list(map(int, input().split()))\n3 B = list(map(int, input().split()))\n4\n5 a, b = [0], [0]\n6 for i in range(N):\n7 \u3000\u3000a.append(a[i] + A[i])\n8 for i in range(M):\n9 \u3000\u3000b.append(b[i] + B[i])\n10\n11 ans, j = 0, M\n12 for i in range(N + 1):\n13 \u3000\u3000if a[i] > K:\n14 \u3000\u3000\u3000\u3000break\n15\u3000\u3000 while b[j] > K - a[i]:\n16 \u3000\u3000\u3000\u3000j -= 1\n17 \u3000\u3000ans = max(ans, i + j)\n18 print(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\u3000\u3000a.append(a[i] + A[i])\nfor i in range(M):\n\u3000\u3000b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n\u3000\u3000if a[i] > K:\n\u3000\u3000\u3000\u3000break\n\u3000\u3000while b[j] > K - a[i]:\n\u3000\u3000\u3000\u3000j -= 1\n\u3000\u3000ans = max(ans, i + j)\nprint(ans)', "def main():\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, b = [0], [0]\n for i in range(N):\n a.append(a[i] + A[i])\n for i in range(M):\n b.append(b[i] + B[i])\n\n ans, j = 0, 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 print(ans)\n\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s476252112', 's514779212', 's519774933', 's925526483'] | [8904.0, 9008.0, 9036.0, 47388.0] | [23.0, 25.0, 26.0, 221.0] | [395, 424, 380, 479] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.