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
u804711544
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\n\nN, M, K = map(int, input().split())\n\nbookA = deque(list(map(int, input().split())), N)\nbookB = deque(list(map(int, input().split())), M)\n\ncnt = 0\nwhile K >= 0:\n if len(bookA) == 0 and len(bookB) == 0:\n break\n elif len(bookA) > 0 and len(bookB) == 0:\n K -= bookA.popleft()\n elif len(bookA) == 0 and len(bookB) > 0:\n K -= bookB.popleft()\n elif len(bookA) > 0 and len(bookB) > 0:\n if bookA[0] >= bookB[0]:\n K -= bookA.popleft()\n else:\n K -= bookB.popleft()\n if K >= 0:\n cnt += 1\n\nprint(cnt)', 'from collections import deque\nimport random\n\n\n"""\ndef mine(k, a, b):\n bookA = deque(a)\n bookB = deque(b)\n\n cnt = 0\n r = k\n while r > 0:\n if len(bookA) == 0 and len(bookB) == 0:\n break\n elif len(bookA) > 0 and len(bookB) == 0:\n r -= bookA.popleft()\n elif len(bookA) == 0 and len(bookB) > 0:\n r -= bookB.popleft()\n elif len(bookA) > 0 and len(bookB) > 0:\n if bookA[0] <= bookB[0]:\n r -= bookA.popleft()\n else:\n r -= bookB.popleft()\n if r >= 0:\n cnt += 1\n return cnt\n"""\n\n\n\ndef tsundoku():\n n, m, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n da = [0]\n db = [0]\n for i in range(n):\n da.append(da[i] + a[i])\n for i in range(m):\n db.append(db[i] + b[i])\n\n cnt = 0\n j = m\n for i in range(n+1):\n if da[i] > k:\n break\n while db[j] > k - da[i]:\n j -= 1\n cnt = max(cnt, i+j)\n\n return print(cnt)\n\n\ntsundoku()\n"""\nfor t in range(100):\n n = random.randint(1, 200000)\n m = random.randint(1, 200000)\n k = random.randint(1, 1000000000)\n a = [random.randint(1, 1000000000) for i in range(n)]\n b = [random.randint(1, 1000000000) for i in range(m)]\n\n res1 = mine(k, a, b)\n res2 = answer(n, m, k, a, b)\n if res1 != res2:\n print(res1, end=\' \')\n print(res2, end=\' \\t\')\n print(a[0:3], b[0:3])\n print(k)\n"""']
['Wrong Answer', 'Accepted']
['s609785454', 's359207950']
[42852.0, 48332.0]
[353.0, 218.0]
[597, 1599]
p02623
u805392425
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>\n#define _GLIBCXX_DEBUG\n\n\nusing namespace std;\ntypedef long long ll;\n\nint N, M;\nll K;\nvector<ll> A;\nvector<ll> B;\n\nbool is_ok(vector<ll> B, int cnt_a, int mid){\n return A[cnt_a] + B[mid] <= K;\n}\n\nint binary_search(vector<ll> B, int cnt_a) {\n int left = -1; // 配列の左端\n int right = B.size(); // 配列の右端\n // 両端の差が1になるまで続ける\n while (right - left > 1){\n int mid = (right + left) / 2; // 区間の真ん中\n if (is_ok(B, cnt_a, mid)) left = mid; // もし調べている対象が「is_okの条件」に当てはまればleftをmidまで移動\n else right = mid; // 当てはまらなければrightをmid-1に移動\n }\n return left;\n}\n\nint main(){\n cin >> N >> M >> K;\n // 0インデックスには何も読まない0という初期値をそのまま入れておく\n A.push_back(0);\n B.push_back(0);\n\n rep(i, N){\n ll a;\n cin >> a;\n A.push_back(a);\n }\n rep(i, M){\n ll b;\n cin >> b;\n B.push_back(b);\n }\n\n rep(i, N) A[i+1] += A[i];\n rep(i, M) B[i+1] += B[i];\n\n int ans = 0;\n int cnt_b;\n rep(cnt_a, N+1){\n if (A[cnt_a] > K) continue;\n cnt_b = binary_search(B, cnt_a);\n ans = max(ans, cnt_a + cnt_b);\n }\n cout << ans << endl;\n}', 'from itertools import accumulate\n\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_acc = [0] + list(accumulate(a)) \nb_acc = [0] + list(accumulate(b)) \n\nans = 0\nfor an in range(n + 1):\n rem = k - a_acc[an]\n if rem < 0:\n break\n\n \n ok = 0\n ng = m + 1 \n \n while abs(ng - ok) > 1:\n mid = (ok + ng) // 2\n \n if b_acc[mid] <= rem:\n \n ok = mid\n else:\n \n ng = mid\n\n bn = ok\n ans = max(ans, an + bn)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s841428973', 's494627996']
[9012.0, 49180.0]
[25.0, 1200.0]
[1380, 884]
p02623
u806976856
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.append("1000000001")\nb.append("1000000001")\na[n]=int(a[n])\nb[m]=int(b[m])\n\nx=0\ny=0\nans=0\ntime=0\n\nfor i in range(n+m):\n if a[x]<=b[y]:\n time+=a[x]\n if time>k:\n time-=a[x]\n print(ans)\n sys.exit()\n x+=1\n ans+=1\n else:\n time+=b[y]\n if time>k:\n time-=b[y]\n print(ans)\n sys.exit() \n y+=1\n ans+=1\nprint(ans)\n\n ', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nA=[0 for i in range(n)]\nB=[0 for i in range(m)]\nA[0]=a[0]\nB[0]=b[0]\nfor i in range(n-1):\n A[i+1]=a[i+1]+A[i]\n\nfor i in range(m-1):\n B[i+1]=b[i+1]+B[i]\n\nans=0\nA.insert(0,0)\nB.insert(0,0)\n\nfor i in range(n+1):\n x=0\n y=m\n j=(x+y)//2\n if A[i]+B[m]<=k:\n ans=max(ans,i+m)\n elif not A[i]+B[0]>k:\n \n \n while y-x>1:\n if A[i]+B[j]<=k:\n x=j\n else:\n y=j\n j=(x+y)//2\n ans=max(ans,i+x)\n \nprint(ans)\n \n \n']
['Runtime Error', 'Accepted']
['s306584407', 's912012334']
[9144.0, 47512.0]
[25.0, 1254.0]
[438, 614]
p02623
u810356688
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 input(): return sys.stdin.readline().rstrip()\nfrom itertools import accumulate\ndef main():\n n, m, k = map(int,input().split())\n A = [0] + list(map(int,input().split()))\n B = [0] + list(map(int,input().split()))\n A = list(accumulate(A))\n B = list(accumulate(B))\n ans = 0\n j = m\n for i in range(n + 1):\n if A[i] > k:\n break\n while A[i] + B[j] > k:\n j -= 1\n ans = max(ans, i + j)\n print(i, j, ans)\n print(ans)\n\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom itertools import accumulate\ndef main():\n n, m, k = map(int,input().split())\n A = [0] + list(map(int,input().split()))\n B = [0] + list(map(int,input().split()))\n A = list(accumulate(A))\n B = list(accumulate(B))\n ans = 0\n j = m\n for i in range(n + 1):\n if A[i] > k:\n break\n while A[i] + B[j] > k:\n j -= 1\n ans = max(ans, i + j)\n print(ans)\n\n\nif __name__=='__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s956104433', 's193893280']
[41868.0, 42060.0]
[327.0, 189.0]
[536, 511]
p02623
u814271993
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans,j=0,M\nfor i in range(N + 1):\n if a[i]>K:\n break\n while b[j] > K - a[i]\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans,j=0,M\nfor i in range(N + 1):\n if a[i]>K:\n break\n while b[j] > K - a[i]\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n', "def main():\n from itertools import chain\n\n N, M, K = map(int, input().split())\n A = map(int, input().split())\n *B, = map(int, input().split())\n\n t = sum(B)\n ans = 0\n j = M\n for i, x in enumerate(chain([0], A)):\n t += x\n while j > 0 and t > K:\n j -= 1\n t -= B[j]\n if t > K: break\n if ans < i + j:\n ans = i + j\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s306585048', 's626179976', 's770660114']
[9052.0, 9044.0, 48724.0]
[24.0, 21.0, 155.0]
[352, 352, 449]
p02623
u821393459
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())\nAs = [int(n) for n in input().split()]\nBs = [int(n) for n in input().split()]\n\na_sum = [0] * (len(As) + 1)\nb_sum = [0] * (len(Bs) + 1)\n\nfor i in range(1, len(As)):\n a_sum[i] = a_sum[i-1] + As[i]\n\nfor j in range(1, len(Bs)):\n b_sum[i] = b_sum[i-1] + Bs[i]\n\nmax_book_num = 0\nj = M\nfor i in range(N+1):\n if a_sum[i] > K:\n continue\n\n while b_sum[j] + a_sum[i] > K:\n j -= 1\n \n max_book_num = max(max_book_num, i + j)\n\n \nprint(max_book_num) \n\n', 'N,M,K = map(int, input().split())\nAs = [int(n) for n in input().split()]\nBs = [int(n) for n in input().split()]\n\na_sum = [0]\nb_sum = [0]\n\nfor i in range(len(As)):\n a_sum.append(a_sum[-1] + As[i])\n\nfor j in range(len(Bs)):\n b_sum.append(b_sum[-1] + Bs[j])\n\n \nmax_book_num = 0\nj = M\nfor i in range(N+1):\n if a_sum[i] > K:\n continue\n\n while b_sum[j] + a_sum[i] > K:\n j -= 1\n \n max_book_num = max(max_book_num, i + j)\n\n \nprint(max_book_num) \n\n']
['Runtime Error', 'Accepted']
['s724210755', 's549133323']
[40524.0, 47352.0]
[261.0, 302.0]
[513, 481]
p02623
u823585596
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()))\nx,y=[0],[0]\nfor i in range(n):\n x.append(a[i]+x[i])\nfor j in range(m):\n y.append(b[j]+y[j])\n\nans=0\nj=m\nfor i in range(n+1):\n if x[i]>k:\n break\n while y[j]>k-x[i]:\n j-=1\n ans=max\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx,y=[0],[0]\nfor i in range(n):\n x.append(a[i]+x[i])\nfor j in range(m):\n y.append(b[j]+y[j])\n\nans=0\nj=m\nfor i in range(N+1):\n if x[i]>k:\n break\n while y[j]>k-x[i]:\n j-=1\n ans=max\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx=[0]*n\ny=[0]*m\nx[0]=a[0]\ny[0]=b[0]\nfor i in range(0,n-1):\n x[i+1]=x[i]+a[i+1]\nfor i in range(0,m-1):\n y[i+1]=y[i]+b[i+1]\nprint(x)\nprint(y)\nans,j=0,m\nfor i in range(n):\n if x[i]>k:\n break\n while y[j-1]>k-x[i]:\n j-=1\n ans=max(i+1+j,ans)\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx,y=[0],[0]\nfor i in range(n):\n x.append(a[i]+x[i])\nfor j in range(m):\n y.append(b[j]+y[j])\n\nans=0\nj=m\nfor i in range(n+1):\n if x[i]>k:\n break\n while y[j]>k-x[i]:\n j-=1\n ans=max(i+j,ans)\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s046349934', 's341652737', 's683573045', 's991458001']
[47480.0, 47436.0, 56016.0, 47400.0]
[265.0, 190.0, 402.0, 303.0]
[314, 314, 372, 323]
p02623
u823885866
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
["import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: map(int, sys.stdin.readline().split())\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\nn, m, k = rm()\na = rl()\nb = list(itertools.accumulate(rl()))\nif a[0] > k:\n ans = 0\nelse:\n left = 0\n right = m\n while right - left > 1:\n j = (left + right) // 2\n if b[j] > k:\n right = j\n else:\n left = j\n ans = left + 1\nt = 0\nb0 = b[0]\nfor cnt, i in enumerate(a, 1):\n t += i\n if t > k:\n break\n if b0 > t-k:\n ans = max(ans, cnt)\n continue\n left = 0\n right = m\n while right - left > 1:\n j = (left + right) // 2\n if b[j] > k-t:\n right = j\n else:\n left = j\n ans = max(ans, cnt + left + 1)\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: map(int, sys.stdin.readline().split())\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\nn, m, k = rm()\na = rl()\nb = list(itertools.accumulate(rl()))\nif a[0] > k:\n ans = 0\nelse:\n left = 0\n right = m\n while right - left > 1:\n j = (left + right) // 2\n if b[j] > k:\n right = j\n else:\n left = j\n ans = left + 1\nt = 0\nb0 = b[0]\nfor cnt, i in enumerate(a, 1):\n t += i\n if t > k:\n break\n if b0 > k-t:\n ans = max(ans, cnt)\n continue\n left = 0\n right = m\n while right - left > 1:\n j = (left + right) // 2\n if b[j] > k-t:\n right = j\n else:\n left = j\n ans = max(ans, cnt + left + 1)\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"]
['Wrong Answer', 'Accepted']
['s141118684', 's917234112']
[59460.0, 59388.0]
[281.0, 1206.0]
[1055, 1055]
p02623
u823926181
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 j in range(M):\n b.append(b[i] + B[i])\n\nans = 0\nj = 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(i + j, ans)\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 j in range(M):\n b.append(b[j] + B[j])\n\nans = 0\nj = 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(i + j, ans)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s173824780', 's095490390']
[9164.0, 47648.0]
[24.0, 302.0]
[364, 366]
p02623
u829391045
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 bins(a, x):\n l = -1\n h = len(a)\n while (h-l) > 1:\n m = (l+h)//2\n if x > a[m]:\n l = m\n else:\n h = m\n return l + 1\nn, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\npa, pb = [0] * (n+1), [0] * (m+1)\nfor i in range(n):\n pa[i+1] = pa[i] + a[i]\nfor i in range(m):\n pb[i+1] = pb[i] + b[i]\nm = 0\nfor i in range(len(pa)):\n if pa[i] > k:\n break\n v = k - pa[i]\n bv = bins(pb, v)\n if bv:\n m = max(m, bv+i)\n \nprint(m)\n', 'n, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\npa, pb = [0] * (n+1), [0] * (m+1)\nfor i in range(n):\n pa[i+1] = pa[i] + a[i]\nfor i in range(m):\n pb[i+1] = pb[i] + b[i]\nm = 0\nfor i in range(len(pa)):\n if pa[i] > k:\n break\n v = k - pa[i]\n for j in range(len(pb)-1, -1, -1):\n if pb[j] < v:\n break\n else:\n m = max(m, i+j)\nprint(m)\n', 'def bins(a, x):\n l = -1\n h = len(a)\n while (h-l) > 1:\n m = (l+h)//2\n if x >= a[m]:\n l = m\n else:\n h = m\n return l\nn, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\npa, pb = [0] * (n+1), [0] * (m+1)\nfor i in range(n):\n pa[i+1] = pa[i] + a[i]\nfor i in range(m):\n pb[i+1] = pb[i] + b[i]\nm = 0\nfor i in range(len(pa)):\n if pa[i] > k:\n break\n v = k - pa[i]\n bv = bins(pb, v) + 1\n m = max(m, bv+i)\n \nprint(m)\n', 'n, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\npa, pb = [0] * (n+1), [0] * (m+1)\nfor i in range(n):\n pa[i+1] = pa[i] + a[i]\nfor i in range(m):\n pb[i+1] = pb[i] + b[i]\nmx = 0\nfor i in range(len(pa)):\n j = m\n if pa[i] > k:\n break\n v = k - pa[i]\n while pb[j] <= v:\n j -= 1\n mx = max(mx, i+j)\nprint(mx)\n', 'def bins(a, x):\n l = -1\n h = len(a)\n while (h-l) > 1:\n m = (l+h)//2\n if x >= a[m]:\n l = m\n else:\n h = m\n return l\nn, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\npa, pb = [0] * (n+1), [0] * (m+1)\nfor i in range(n):\n pa[i+1] = pa[i] + a[i]\nfor i in range(m):\n pb[i+1] = pb[i] + b[i]\nm = 0\nfor i in range(len(pa)):\n if pa[i] > k:\n break\n v = k - pa[i]\n bv = bins(pb, v)\n m = max(m, bv+i)\n \nprint(m)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s674917499', 's762575061', 's893833028', 's954251201', 's758990297']
[48640.0, 47364.0, 48656.0, 47368.0, 48544.0]
[723.0, 2207.0, 755.0, 288.0, 704.0]
[568, 443, 554, 401, 550]
p02623
u830054172
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.
['\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ntime = 0\ncnt = 0\nb = []\n\nfor i in B:\n if i+time>K:\n break\n time += i\n cnt += 1\n b.append(i)\n\nb.reverse()\n# print(b)\n# print(cnt)\nbi = 0\nfor i in range(N):\n if time+A[i] <= K:\n cnt += 1\n time += A[i]\n else:\n if len(b)-1 >= bi:\n if A[i] <= b[bi]:\n time -= b[bi]-A[i]\n bi += 1\n else:\n break\n # print("a")\n # print(time+A[i])\n \n # print(time)\n\ntime2 = 0\ncnt2 = 0\na = []\n\nfor i in A:\n if i+time>K:\n break\n time2 += i\n cnt2 += 1\n a.append(i)\n\na.reverse()\n# print(b)\n# print(cnt)\nai = 0\nfor i in range(N):\n if time2+B[i] <= K:\n cnt2 += 1\n time2 += B[i]\n else:\n if len(a)-1 >= ai:\n if B[i] <= a[ai]:\n time2 -= a[ai]-B[i]\n ai += 1\n else:\n break\n # print("a")\n # print(time+A[i])\n \n # print(time)\n\n\nprint(max((cnt, cnt2))\n\n\'\'\'\n5 3 8\n5 0 0 1 1\n1 2 1000\n\'\'\'', 'from itertools import accumulate\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\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\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s786976084', 's806958541']
[9000.0, 42848.0]
[31.0, 239.0]
[1127, 335]
p02623
u830588156
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 = 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(N):\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 \n print(ans)\n \nif __name__ == '__main__':\n main()", "def main():\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_sum = 0\n A_max = N\n tmp_sum = 0\n if A[0] > K:\n flag = False\n else:\n flag = True\n for i in range(N):\n tmp_sum += A[i]\n if tmp_sum > K:\n A_max = i\n break\n else:\n A_sum = tmp_sum\n \n ans = A_max\n tmp_ans = ans\n \n B_i = 0\n time = K - A_sum\n count = 0\n for i in range(-1,A_max):\n if i != -1 and flag:\n A_i = A_max -1 -i\n time += A[A_i]\n count = -1\n \n if i == -1 or flag:\n tmp_time = time\n next_B_i = B_i\n for j in range(B_i,M):\n tmp_time -= B[j]\n if tmp_time >= 0:\n next_B_i += 1\n count += 1\n time = tmp_time\n else:\n break\n \n B_i = next_B_i\n tmp_ans += count\n if count >= 0:\n ans = tmp_ans\n \n print(ans)\n \nif __name__ == '__main__':\n main()", "def main():\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 \n print(ans)\n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s408104981', 's408699679', 's207903029']
[47292.0, 39960.0, 47460.0]
[231.0, 244.0, 234.0]
[489, 1192, 489]
p02623
u833492079
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 io\nimport sys\n\n_INPUT = """\\\n1 4 120\n100 1 1 1 1 1 1 1 1 1 1\n80 10 10 10 10\n"""\nsys.stdin = io.StringIO(_INPUT)\n\n####################################################################\nimport sys\ndef p(*_a):\n # return\n _s=" ".join(map(str,_a))\n #print(_s)\n sys.stderr.write(_s+"\\n")\n####################################################################\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\n\nfrom itertools import accumulate\nC = accumulate(A)\nD = accumulate(B)\n\nE = []\nF = []\nfor c in C:\n if c > K: break\n E.append(c)\n\nfor d in D:\n if d > K: break\n F.append(d)\n\np(*E)\np(*F)\n\nc = d = 0\nans = k = 0\n\n\nfor i, e in enumerate(E):\n for j, f in enumerate(F):\n if e + f > K: break\n ans = max(ans, i+1+j+1)\n\nprint(ans)\n', 'import io\nimport sys\n\n_INPUT = """\\\n1 4 120\n100 1 1 1 1 1 1 1 1 1 1\n80 10 10 10 10\n"""\nsys.stdin = io.StringIO(_INPUT)\n\n####################################################################\nimport sys\ndef p(*_a):\n return\n _s=" ".join(map(str,_a))\n #print(_s)\n sys.stderr.write(_s+"\\n")\n####################################################################\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\n\nfrom itertools import accumulate\nC = accumulate(A)\nD = accumulate(B)\n\nE = [0]\nF = [0]\nfor c in C:\n if c > K: break\n E.append(c)\n\nfor d in D:\n if d > K: break\n F.append(d)\n\np(*E)\np(*F)\n\nc = d = 0\nans = k = 0\n\nfor i, e in enumerate(E):\n for j, f in enumerate(F):\n if e + f > K: break\n ans = max(ans, i+j)\n\nprint(ans)\n', '# import io\n# import sys\n\n# _INPUT = """\\\n# 1 4 120\n# 100 1 1 1 1 1 1 1 1 1 1\n# 80 10 10 10 10\n# """\n\n\n####################################################################\nimport sys\ndef p(*_a):\n return\n _s=" ".join(map(str,_a))\n #print(_s)\n sys.stderr.write(_s+"\\n")\n####################################################################\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\nfrom itertools import accumulate\nA = list(accumulate(a))\nB = list(accumulate(b))\n\np(*A)\np(*B)\n\nfrom bisect import bisect_right as br\n\nans = 0\n\n\n\n\nA = [0] + A\nfor a, ka in enumerate(A):\n if ka > K: break\n\n b = br(B, K - ka) \n ans = max(ans, a + b)\n\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s036562222', 's938802703', 's183776151']
[9072.0, 9080.0, 50768.0]
[32.0, 33.0, 277.0]
[814, 809, 1154]
p02623
u835283937
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 = deque([int(a) for a in input().split()])\n B = deque([int(b) for b in input().split()])\n Bsum = sum(B)\n ans = Asum = 0\n idx_b = len(B) - 1\n\n A.appendleft(0)\n\n for i in range(len(A)):\n Asum += A[i]\n\n for j in range(idx_b + 1):\n if Asum + Bsum > K:\n if idx_b >= 0:\n Bsum -= B[idx_b]\n idx_b -= 1\n else:\n break\n else:\n break\n\n if Asum + Bsum <= K:\n ans = max(ans, i + (idx_b + 1))\n\n print(ans)\n \nif __name__ == "__main__":\n main()', 'def main4():\n N, M, K = map(int, input().split())\n A = [int(a) for a in input().split()]\n B = [int(b) for b in input().split()]\n Bsum = sum(B)\n ans = Asum = 0\n idx_b = len(B) - 1\n\n for i in range(N + 1):\n\n if i == 0:\n Asum += 0\n else:\n Asum += A[i - 1]\n\n while Asum + Bsum > K:\n if idx_b >= 0:\n Bsum -= B[idx_b]\n idx_b -= 1\n else:\n break\n\n if Asum + Bsum <= K:\n ans = max(ans, i + idx_b + 1)\n\n print(ans)\n\nif __name__ == "__main__":\n main4()']
['Runtime Error', 'Accepted']
['s585473133', 's545699113']
[9208.0, 40660.0]
[26.0, 205.0]
[665, 596]
p02623
u840310460
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.
['5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000', '# %%\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()]\n\n# %%\nAA = [0] * (N + 1)\nBB = [0] * (M + 1)\nfor i, v in enumerate(A):\n AA[i + 1] += v + AA[i]\nfor i, v in enumerate(B):\n BB[i + 1] += v + BB[i]\n\nans = 0\nb_cnt = M\nfor a_cnt in range(N + 1):\n if AA[a_cnt] > K:\n continue\n while AA[a_cnt] + BB[b_cnt] > K:\n b_cnt -= 1\n\n ans = max(ans, a_cnt + b_cnt)\n\nprint(ans)\n\n\n']
['Runtime Error', 'Accepted']
['s297725672', 's802577348']
[8940.0, 47688.0]
[29.0, 328.0]
[104, 466]
p02623
u842388336
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 = list(map(int, input().split(' ')))\nb_list = list(map(int, input().split(' ')))\na_sum = 0\nb_sum = sum(b_list)\n\nj = m\nbest=0\nfor i, a in enumerate(a_list):\n a_sum+=a\n if a_sum>k:\n break\n while ((a_sum + b_sum) > k) & (j>=0):\n b_sum-=b_list[j]\n j-=1\n \n best = max(best,i+j+2)\n \n \n \nprint(best)", 'import math\n\na, b, k = map(int, input().split())\na_list = list(map(int, input().split()))\na_list = a_list[::-1]\n\nb_list = list(map(int, input().split()))\nb_list = b_list[::-1]\n\nlist_ = []\ncnt=0\nfinish_flg = False\njikan = 0\nwhile (len(a_list)!=0) & (len(b_list)!=0):\n a_top = a_list[-1]\n b_top = b_list[-1]\n\n if a_top<b_top:\n list_.append(a_top)\n a_list.pop()\n else:\n list_.append(b_top)\n b_list.pop()\n \nlist_ = list_ + a_list + b_list\n\nif sum(list_)<=k:\n print(len(list_))\nelse:\n left = 0\n right = len(list_)\n while abs(left-right)>1:\n mid = (left+right) // 2\n if sum(list_[:mid])<=k:\n left = mid\n else:\n right = mid\n\n print(len(list_[left]))', "n, m, k = map(int, input().split(' '))\na_list = list(map(int, input().split(' ')))\nb_list = list(map(int, input().split(' ')))\nsa = [0] * (n+1)\nsb = [0] * (m+1)\n\nfor i in range(n):\n sa[i+1] = a_list[i] + sa[i]\nfor j in range(m):\n sb[j+1] = b_list[j] + sb[j]\n\nbest=0\nr = m\nfor a in a_list:\n if a>k:\n break\n while ((a + sb[r]) > k) & (r>=0):\n r-=1\n \n best = max(best,i+j+2)\n \n \n \nprint(best)", "n, m, k = map(int, input().split(' '))\na_list = list(map(int, input().split(' ')))\nb_list = list(map(int, input().split(' ')))\nsa = [0] * (n+1)\nsb = [0] * (m+1)\n\nfor i in range(n):\n sa[i+1] = a_list[i] + sa[i]\nfor j in range(m):\n sb[j+1] = b_list[j] + sb[j]\n\nbest=0\nr = m\nfor i, a in enumerate(sa):\n if a>k:\n break\n while ((a + sb[r]) > k) & (r>=0):\n r-=1\n \n best = max(best,i+r)\n \n \n \nprint(best)"]
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s114101152', 's362846234', 's993339756', 's582338673']
[40688.0, 42144.0, 47504.0, 47692.0]
[186.0, 291.0, 302.0, 311.0]
[363, 687, 412, 420]
p02623
u842878495
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 *\n\nN, M, K = [int(n) for n in input().split()]\nA = [x for x in accumulate([int(n) for n in input().split()])]\nB = [x for x in accumulate([int(n) for n in input().split()])]\nans = 0\na = bisect(A, K)\nfor i in range(a-1, -1, -1):\n b = bisect(B, K-A[i])\n ans = max(ans, i+b)\nprint(ans)\n', 'from itertools import accumulate\nfrom bisect import *\n\nN, M, K = [int(n) for n in input().split()]\nA = [0]+[x for x in accumulate([int(n) for n in input().split()])]\nB = [0]+[x for x in accumulate([int(n) for n in input().split()])]\nans = 0\na = bisect_left(A, K)\nfor i in range(a):\n b = bisect_left(B, K-A[i])\n ans = max(ans, i+b)\nprint(ans)\n', 'from itertools import accumulate\nfrom bisect import *\n\nN, M, K = [int(n) for n in input().split()]\nA = [0]+[x for x in accumulate([int(n) for n in input().split()])]\nB = [0]+[x for x in accumulate([int(n) for n in input().split()])]\n#print(A)\n\nans = 0\na = bisect_right(A, K)\n#print(a)\nfor i in range(a):\n b = bisect_right(B, K-A[i])\n ans = max(ans, i+b)\n# print(ans, i, b)\nprint(ans-1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s351073226', 's522438542', 's872318240']
[45148.0, 46736.0, 44708.0]
[268.0, 268.0, 266.0]
[336, 344, 398]
p02623
u843135954
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\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\na = na()\nb = na()\naa = [0]\nbb = [0]\n\nfor i in a:\n aa.append(aa[-1]+i)\nfor i in b:\n bb.append(bb[-1]+i)\n\nimport bisect\nans = 0\nfor i in range(n+1):\n if aa[i] > k:\n break\n kk = k-aa[i]\n ans = max(ans, i+bisect.bisect_left(bb,kk))\n\nprint(ans)', 'import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\na = na()\nb = na()\naa = [0]\nbb = [0]\n\nfor i in a:\n aa.append(aa[-1]+i)\nfor i in b:\n bb.append(bb[-1]+i)\n\nimport bisect\nans = 0\nfor i in range(n+1):\n if aa[i] > k:\n break\n kk = k-aa[i]\n ans = max(ans, i+bisect.bisect_right(bb,kk)-1)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s701752956', 's723644158']
[47520.0, 47840.0]
[322.0, 332.0]
[493, 496]
p02623
u844646164
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['import bisect\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nca = A[:]\ncb = B[:]\n\nfor i in range(N-1):\n ca[i+1] += ca[i]\nfor i in range(M-1):\n cb[i+1] += cb[i]\nprint(ca, cb)\nans = 0\nfor i in range(N):\n if ca[i] <= K:\n idx = bisect.bisect_right(cb, K-ca[i])\n else:\n continue\n \n ans = max(ans, i+idx+1)\n\n\nfor i in range(M):\n if cb[i] <= K:\n idx = bisect.bisect_right(cb, K-cb[i])\n else:\n continue\n \n ans = max(ans, i+idx+1)\nprint(ans)\n', 'import bisect\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nca = A[:]\ncb = B[:]\n\nfor i in range(N-1):\n ca[i+1] += ca[i]\nfor i in range(M-1):\n cb[i+1] += cb[i]\n\nans = 0\nfor i in range(N):\n if ca[i] <= K:\n idx = bisect.bisect_right(cb, K-ca[i])\n else:\n continue\n if 0 < idx < M:\n j = idx - 1\n elif idx == 0:\n j = 0\n elif idx == M:\n j = M\n \n ans = max(ans, (i+1)+j)\n\nprint(ans)\n', 'import bisect\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nca = A[:]\ncb = B[:]\n\nfor i in range(N-1):\n ca[i+1] += ca[i]\nfor i in range(M-1):\n cb[i+1] += cb[i]\n\nans = 0\nfor i in range(N):\n if ca[i] <= K:\n idx = bisect.bisect_right(cb, K-ca[i])\n else:\n continue\n \n ans = max(ans, i+idx+1)\n\nfor i in range(M):\n if cb[i] <= K:\n idx = bisect.bisect_right(ca, K-cb[i])\n else:\n continue\n \n ans = max(ans, i+idx+1)\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s354255131', 's903893646', 's633617938']
[54840.0, 47484.0, 47392.0]
[540.0, 377.0, 505.0]
[516, 461, 502]
p02623
u845650912
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int,input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nimport numpy as np\n\na =[]\n\nif K \n\nflag = True\nwhile flag:\n if A[0] >= K or B[0] >= K:\n flag = False\n elif not A and not B:\n flag = False\n elif not A:\n a.append(B[0])\n B = B[1:]\n elif not B:\n a.append(A[0])\n A = A[1:]\n elif A[0] <= B[0]:\n a.append(A[0])\n A = A[1:]\n #elif A[0] > B[0]:\n else:\n a.append(B[0])\n B = B[1:]\n\nres = np.cumsum(a)\nr = list(res)\n\ncnt = 0\nfor i in r:\n if i <= K:\n cnt += 1\n else:\n break\nprint(cnt)', 'N, M, K = map(int,input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nimport numpy as np\n\na =[]\nflag = True\nwhile flag:\n if A[0] >= K or B[0] >= K:\n flag = False\n elif not A and not B:\n flag = False\n elif not A:\n a.append(B[0])\n B = B[1:]\n elif not B:\n a.append(A[0])\n A = A[1:]\n elif A[0] <= B[0]:\n a.append(A[0])\n A = A[1:]\n else:\n a.append(B[0])\n B = B[1:]\n\nres = np.cumsum(a)\nr = list(res)\n\ncnt = 0\nfor i in r:\n if i <= K:\n cnt += 1\n else:\n break\nprint(cnt)', '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\nj=M\nans = 0\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K -a[i]:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s436393144', 's561481623', 's222390868']
[8960.0, 45084.0, 47688.0]
[32.0, 2207.0, 282.0]
[638, 607, 352]
p02623
u861886710
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())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\n\nacum1=[0]\n\n\nfor i in range(n):\n\t\n \n\tacum1.append(acum[-1]+arr1[i])\n \nacum2 = [0]\n\nfor i in range(m):\n\t\n \n\tacum2.append(acum2[-1]+arr2[i])\n\nans = 0\nfor i in range(n+1):\n\t\n \n\tif acum1[i] > k:\n \tbreak\n \n \n \n while acum2[j]>k - acum1[i] and j>0:\n \tj -= 1\n ans = max(ans, i+j)\nprint(ans)', 'n, m, k=map(int, input().split())\narr1 = list(map(int, input().split()))\narr2 = list(map(int, input().split()))\n\nacum1=[0]\n\n\nfor i in range(n):\n\tacum1.append(acum[-1]+arr1[i])\n \nacum2 = [0]\n\nfor i in range(m):\n\tacum2.append(acum2[-1]+arr2[i])\n\nans = 0\nfor i in range(n+1):\n\tif acum1[i] > k:\n \tbreak\n while acum2[j]>k - acum1[i] and j>0:\n \tj -= 1\n ans = max(ans, i+j)\nprint(ans)', '\nN, M, X = map(int, input().split())\nC = []\nA = []\nfor i in range(N):\n t = list(map(int, input().split()))\n C.append(t[0])\n A.append(t[1:])\n \nresult = -1\n\n\nfor i in range(1 << N):\n \n t = [0] * M\n c = 0\n #print(i)\n for j in range(N):\n #print(j)\n if(i >> j ) & 1 == 0 :\n continue\n c += C[j]\n for k in range(M):\n t[k] += A[j][k]\n if all(x >= X for x in t):\n if result == -1:\n result = c\n else:\n result = min(result, c)\nprint(result)', 'n,m,k=map(int,input().split())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\nacum1=[0]\n\nfor i in range(n): \n\t\n \n acum1.append(acum1[-1]+arr1[i])\nacum2=[0]\nfor i in range(m):\n acum2.append(acum2[-1]+arr2[i])\nans=0\nj=m\nfor i in range(n+1):\n \n \n \n if acum1[i]>k:\n break\n \n \n \n while acum2[j]>k-acum1[i] and j>0: \n j-=1\n ans=max(ans,i+j)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s454750838', 's647799342', 's746570241', 's389509415']
[9052.0, 8940.0, 43628.0, 47524.0]
[27.0, 24.0, 120.0, 286.0]
[999, 444, 793, 986]
p02623
u865119809
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()))\n\nb = list(map(int,input().split()))\n\nc = [0]\nd = 0\nfor i in range(n):\n d += a[i]\n c.append(d)\n\ne = [0]\nf = 0\nfor i in range(n):\n f += b[i]\n e.append(f)\n\n\nans = 0\nj = q-1\nfor i in range(n):\n if c[i] > k:\n break\n else:\n while c[i] + e[j] > k:\n j -= 1\n ans = max(i + j,ans)\n\nprint(ans)', '#c\nn,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\n\nb = list(map(int,input().split()))\n\nc = [0]\nd = 0\nfor i in range(n):\n d += a[i]\n c.append(d)\n\ne = [0]\nf = 0\nfor i in range(m):\n f += b[i]\n e.append(f)\n\n\nans = 0\nj = q-1\nfor i in range(n):\n if c[i] > k:\n break\n else:\n while c[i] + e[j] > k:\n j -= 1\n ans = max(i + j,ans)\n\nprint(ans)', 'n,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\n\nb = list(map(int,input().split()))\n\n\nc = [0]\nd = 0\nfor i in range(n):\n d += a[i]\n c.append(d)\n\ne = [0]\nf = 0\nfor i in range(m):\n f += b[i]\n e.append(f)\n\n\nans = 0\nj = m\nfor i in range(n+1):\n if c[i] > k:\n break\n else:\n while c[i] + e[j] > k:\n j -= 1\n ans = max(i + j,ans)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s514345424', 's911986623', 's872388401']
[47348.0, 47388.0, 47372.0]
[187.0, 204.0, 308.0]
[397, 400, 398]
p02623
u869519920
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 = list(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]\nfor i in range(1,m):\n b[i] += b[i-1]\na_max = 0\nfor i in range(n, 0, -1)\n if a[i-1] <= k:\n a_max = i\n break\nb_max = 0\nfor i in range(m, 0, -1)\n if a[i-1] <= k:\n b_max = i\n break\n \nans = 0\nfor i in range(a_max, 0, -1):\n p = 0\n q = 0\n if a[i-1] <= k:\n p = a[i-1]\n q = i\n for j in range(b_max, 0, -1):\n if p + b[j-1] <= k:\n ans = max(ans, q + j)\n \nprint(ans)', 'import sys\nn, 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.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans = 0\nj = m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while a[i] + b[j] > k:\n j -= 1\n ans = max(ans, i + j)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s359726571', 's341790835']
[8952.0, 47140.0]
[24.0, 286.0]
[557, 368]
p02623
u869731337
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()))\ntime=0\ncount=0\nl=len(a)+len(b)\nfor i in range(l)\n if len(b)>0:\n if len(a)>0:\n if a[0]<b[0]:\n if time+a[0]<=k:\n time+=a[0]\n a.pop(0)\n else:\n break\n else:\n if time+b[0]<=k:\n time+=b[0]\n b.pop(0)\n else:\n break\n else:\n if time+b[0]<=k:\n time+=b[0]\n b.pop(0)\n else:\n break\n elif len(a)>0:\n if time+a[0]<=k:\n time+=a[0]\n a.pop(0)\n else:\n break\n else:\n break\n count+=1\nprint(count)', 'N, M, K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\na, b=[0], [0]\nfor\u3000i\u3000in\u3000range(N):\n a.append(a[i]+A[i])\nfor\u3000i\u3000in\u3000range(M):\n b.append(b[i]+B[i])\nans, j=0, M\nfor\u3000i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=117ans=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', 'Accepted']
['s266778544', 's744345901', 's335145088']
[9032.0, 8972.0, 47548.0]
[22.0, 25.0, 296.0]
[814, 324, 329]
p02623
u870518235
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.
['M,N,K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nres = 0\ntime = 0\n\nwhile time <= K:\n if A[0] <= B[0]:\n time = time + A.pop(0)\n else:\n time = time + B.pop(0)\n res += 1\n\nprint(res)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\nlst = [0]*(N+1)\n\nfor i in range(N+1):\n time = 0\n time = sum(A[0:i])\u3000\n if time > K:\n break \n else:\n for j in range(M):\n # \n if time + B[j] <= K:\n time = time + B[j]\n else:\n lst[i] = i + j\n break\n\nres = max(lst)\nprint(res)\n\n"""\n3 4 240\n60 90 120\n80 150 80 150\n\n3 4 730\n60 90 120\n80 150 80 150\n"""', 'M, N, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nlst = [0]*(M+1)\nfor i in range(M+1):\n time = 0\n time = sum(A[0:i])\n if time >= K:\n pass\n else:\n for j in range(N):\n time += B[j]\n if time >= K:\n break\n lst[i] = i + j\n\nres = max(lst)\nprint(res)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans, j = 0, M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s215022076', 's306408016', 's849046086', 's107487388']
[40440.0, 9040.0, 40624.0, 47520.0]
[2206.0, 26.0, 2206.0, 297.0]
[259, 713, 368, 353]
p02623
u871841829
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(1000000)\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nrest = K\nans = 0\n\ndef dfs(cost, aindex, bindex, score):\n\n if K == cost:\n print("1:", score, cost)\n return score\n elif K < cost:\n print("2:", score, cost)\n return score - 1\n \n if aindex == N and bindex == M:\n print("3:", score, cost)\n return score\n\n elif aindex >= N:\n return dfs(cost + B[bindex], aindex, bindex+1, score + 1)\n \n elif bindex >= M:\n return dfs(cost + A[aindex], aindex+1, bindex, score + 1)\n\n else:\n return max(dfs(cost + A[aindex], aindex+1, bindex, score + 1), dfs(cost + B[bindex], aindex, bindex + 1, score + 1))\n\nprint(max(dfs(A[0], 1, 0, 1), dfs(B[0], 0, 1, 1)))', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nAA = list(reversed(A))\nBB = list(reversed(B))\n\nrest = K\nans = 0\n\ndef dfs(cost, aindex, bindex, score):\n\n if K == cost:\n # print("1:", score, cost)\n return score\n elif K < cost:\n # print("2:", score, cost)\n # return score - 2\n return -1\n \n if aindex == N and bindex == M:\n # print("3:", score, cost)\n return score\n\n if aindex >= N:\n return dfs(cost + B[bindex], aindex, bindex+1, score + 1)\n \n elif bindex >= M:\n return dfs(cost + A[aindex], aindex+1, bindex, score + 1)\n\n else:\n return max(dfs(cost + A[aindex], aindex+1, bindex, score + 1), dfs(cost + B[bindex], aindex, bindex + 1, score + 1))\n\nprint(max(dfs(A[0], 1, 0, 1), dfs(B[0], 0, 1, 1)))', 'import sys\nsys.setrecursionlimit(10e9)\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nAA = list(reversed(A))\nBB = list(reversed(B))\n\nrest = K\nans = 0\n\ndef dfs(cost, aindex, bindex, score):\n\n if K == cost:\n # print("1:", score, cost)\n return score\n elif K < cost:\n # print("2:", score, cost)\n return score - 1\n # return -1\n \n if aindex == N and bindex == M:\n # print("3:", score, cost)\n return score\n\n if aindex >= N:\n return dfs(cost + B[bindex], aindex, bindex+1, score + 1)\n \n elif bindex >= M:\n return dfs(cost + A[aindex], aindex+1, bindex, score + 1)\n\n else:\n return max(dfs(cost + A[aindex], aindex+1, bindex, score + 1), dfs(cost + B[bindex], aindex, bindex + 1, score + 1))\n\nprint(max(dfs(A[0], 1, 0, 1), dfs(B[0], 0, 1, 1)))', '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 ai in A:\n a.append(a[-1] + ai)\n\nfor bi in B:\n b.append(b[-1] + bi)\n\n# print(a, b)\nans = 0\nbs = M\nfor i in range(N+1):\n if a[i] > K:\n break\n for j in reversed(range(bs+1)):\n if a[i] + b[j] <= K:\n ans = max(ans, i + j)\n bs = j\n break\n\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s139045554', 's242107945', 's315471442', 's890931137']
[403832.0, 41008.0, 9192.0, 47560.0]
[2337.0, 147.0, 27.0, 373.0]
[821, 850, 889, 431]
p02623
u871934301
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=A[0]\nb=sum(B)\np=0\nfor i in range(N):\n count=a+b\n while count>K:\n count-=B[M-1]\n M-=1\n if i!=N-1:\n a+=A[i+1]\n p=max(p,i+M+1)\n if a>K:\n break\nprint(p)', 'from collections import deque\nN,M,K=map(int,input().split())\nA=deque(map(int,input().split()))\nB=deque(map(int,input().split()))\nif sum(A)+sum(B)<=K:\n print(len(A)+len(B))\nelse:\n ans=0\n count=0\n while count<K and len(A)!=0 and len(B)!=0:\n m=min(A[0],B[0])\n count+=m\n if m==A[0]:\n A.pop(0)\n else:\n B.pop(0)\n ans+=1\n if count<K and len(A)==0:\n while count<K:\n m=B[0]\n count+=m\n B.pop(0)\n ans+=1\n if count<K and len(B)==0:\n while count<K:\n m=A[0]\n count+=m\n A.pop(0)\n ans+=1\n if count>K:\n ans-=1\n print(ans)\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n', 'from collections import deque\nN,M,K=map(int,input().split())\nA=deque(map(int,input().split()))\nB=deque(map(int,input().split()))\nif sum(A)+sum(B)<=K:\n print(len(A)+len(B))\nelse:\n ans=0\n count=0\n A.reverse()\n B.reverse()\n while count<K and len(A)!=0 and len(B)!=0:\n m=min(A[0],B[0])\n count+=m\n if m==A[0]:\n A.popleft()\n else:\n B.popleft()\n ans+=1\n if count>K:\n ans-=1\n if count<K and len(A)==0:\n while count<K:\n m=B[0]\n count+=m\n B.popleft()\n ans+=1\n if count<K and len(B)==0:\n while count<K:\n m=A[0]\n count+=m\n A.popleft()\n ans+=1\n print(ans)\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nc=0\nb=0\nfor i in range(M):\n b+=B[i]\n if b<=K:\n c+=1\n else:\n break\na=0\nb=sum(B)\nj=M\nans=0\nfor i in range(N):\n a+=A[i]\n if a>K:\n break\n while a+b>K:\n b-=B[-1]\n B.pop(-1)\n j-=1\n ans=max(ans,i+j+1)\nans=max(ans,c)\nprint(ans)\n\n\n\n\n\n\n \n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s587947276', 's691467360', 's883260827', 's105310986']
[40536.0, 39380.0, 39636.0, 40364.0]
[259.0, 119.0, 300.0, 269.0]
[290, 830, 883, 600]
p02623
u872923967
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())\narA = list(map(int, input().split()))\narB = list(map(int, input().split()))\n\nidxA = idxB = 0\nreadTime :int = 0\nreadBooks :int = 0\nwhile readTime < k:\n if arA[idxA] <= arA[idxB] and idxA < n:\n readTime += arA[idxA]\n idxA += 1\n else:\n readTime += arB[idxB]\n idxB += 1\n readBooks += 1\n if idxA >= n and idxB >= m:\n break\n\nprint(readBooks)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s869134987', 's072823408']
[40620.0, 47492.0]
[184.0, 307.0]
[419, 362]
p02623
u884323674
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_temp = [int(i) for i in input().split()]\nB_temp = [int(i) for i in input().split()]\n\nA, B = [0]*(N+1), [0]*(M+1)\nfor i in range(1, N):\n A[i] = A[i-1] + A_temp[i-1]\n \nfor j in range(1, M):\n B[j] = B[j-1] + B_temp[j-1]\n \nans = 0\nfor a in range(N+1):\n if A[a] > K:\n break\n for b in range(ans-a+1, M+1):\n if A[a] + B[b] > K:\n break\n ans = max(ans, a+b)\n \nprint(ans)', 'N, M, K = map(int, input().split())\nA_temp = [int(i) for i in input().split()]\nB_temp = [int(i) for i in input().split()]\n\nA, B = [0]*(N+1), [0]*(M+1)\nfor i in range(1, N):\n A[i] = A[i-1] + A_temp[i-1]\n \nfor j in range(1, M):\n B[j] = B[j-1] + B_temp[j-1]\n \nans = 0\nfor a in range(N+1):\n if A[a] > K:\n break\n for b in range(M+1):\n if A[a] + B[b] > K:\n break\n ans = max(ans, a+b)\n \nprint(ans)', 'import sys\ninput = sys.stdin.readline\n\nN, M, K = map(int, input().split())\nA_temp = [int(i) for i in input().split()]\nB_temp = [int(i) for i in input().split()]\n\nA, B = [0]*(N+1), [0]*(M+1)\nfor i in range(1, N+1):\n A[i] = A[i-1] + A_temp[i-1]\nfor i in range(1, M+1):\n B[i] = B[i-1] + B_temp[i-1]\n\nans = 0\nb = M\nfor a in range(N+1):\n if A[a] > K:\n break\n while B[b] > K - A[a]:\n b -= 1\n ans = max(ans, a + b)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s522918585', 's659121222', 's638937117']
[48576.0, 48420.0, 48760.0]
[405.0, 2207.0, 311.0]
[456, 447, 447]
p02623
u891516200
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\nfrom sys import exit\n\nN, M, K = [int(x) for x in input().split()]\n\na_book = [0]\nfor index, i in enumerate(input().split(), 1):\n a_book.append(a_book[index-1] + int(i))\n\nb_book = [0]\nfor index, i in enumerate(input().split(), 1):\n b_book.append(b_book[index-1] + int(i))\n\nif a_book[1] > K and b_book[1] > K:\n print(0)\n exit()\n\nif a_book[-1] + b_book[-1] < K:\n print(N + M)\n exit()\n\nsearch = deque()\ncheck = {}\n\n\ndef search_count(v):\n search.appendleft(v)\n while search:\n v = search.popleft()\n\n if not v in check:\n check[v] = v[0] + v[1]\n\n if not (v[0] + 1, v[1]) in check:\n if v[0] + 1 <= N:\n if a_book[v[0] + 1] + b_book[v[1]] <= K:\n search.appendleft((v[0] + 1, v[1]))\n\n if not (v[0], v[1] + 1) in check:\n if v[1] + 1 <= M:\n if a_book[v[0]] + b_book[v[1] + 1] <= K:\n search.appendleft((v[0], v[1] + 1))\n\n\nsearch_count((0, 0))\n\nprint(check)\n\nprint(max(check.values()))\n', 'from collections import deque\nfrom sys import exit\n\nN, M, K = [int(x) for x in input().split()]\n\na_book = [0]\nfor index, i in enumerate(input().split(), 1):\n if a_book[index-1] + int(i) <= K:\n a_book.append(a_book[index-1] + int(i))\n else:\n break\n\nb_book = [0]\nfor index, i in enumerate(input().split(), 1):\n if b_book[index-1] + int(i) <= K:\n b_book.append(b_book[index-1] + int(i))\n else:\n break\n\nsearch = deque()\ncheck = {}\n\n\ndef search_count(v):\n search.appendleft(v)\n while search:\n v = search.popleft()\n\n if not v in check:\n check[v] = v[0] + v[1]\n\n if not (v[0] + 1, v[1]) in check:\n if v[0] + 1 <= N:\n if a_book[v[0] + 1] + b_book[v[1]] <= K:\n search.appendleft((v[0] + 1, v[1]))\n\n if not (v[0], v[1] + 1) in check:\n if v[1] + 1 <= M:\n if a_book[v[0]] + b_book[v[1] + 1] <= K:\n search.appendleft((v[0], v[1] + 1))\n\n\nsearch_count((0, 0))\n\nprint(max(check.values()))\n', 'from bisect import bisect_right\nfrom itertools import accumulate\n\nN, M, K = [int(x) for x in input().split()]\n\na_book = [0] + list(accumulate([int(x) for x in input().split()]))\nb_book = [0] + list(accumulate([int(x) for x in input().split()]))\n\ncheck = {}\n\nmax_books = 0\n\nfor i, a in enumerate(a_book):\n if a > K:\n break\n\n b_pos = bisect_right(b_book, K - a)\n\n if max_books < b_pos - 1 + i:\n max_books = b_pos - 1 + i\n\nprint(max_books)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s026255883', 's560423980', 's723347484']
[340868.0, 329340.0, 44324.0]
[2214.0, 2216.0, 270.0]
[1084, 1080, 460]
p02623
u892340697
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\ntmp = []\ns = 0\nfor i in a:\n if s + i <= k:\n tmp.append(i)\n s += i\n else:\n break\na = tmp\ntmp = []\ns = 0\nfor i in b:\n if s + i <= k:\n tmp.append(i)\n s += i\n else:\n break\nb = tmp\nline = b[::-1] + a\nprint(line)\nans = 0\nright = 0\nsum_ = 0\nfor left in range(len(line)):\n while right < len(line) and sum_ + line[right] <= k:\n sum_ += line[right]\n right += 1\n l = right -left \n if l > ans:\n ans = l\n\n if right == left: right += 1\n else: sum_ -= line[left]\n\nprint(ans) ', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ntmp = []\ns = 0\nfor i in a:\n if s + i <= k:\n tmp.append(i)\n s += i\n else:\n break\na = tmp\ntmp = []\ns = 0\nfor i in b:\n if s + i <= k:\n tmp.append(i)\n s += i\n else:\n break\nb = tmp\nline = b[::-1] + a\n\nans = 0\nright = 0\nsum_ = 0\nfor left in range(len(line)):\n while right < len(line) and sum_ + line[right] <= k:\n sum_ += line[right]\n right += 1\n l = right -left \n if l > ans:\n ans = l\n\n if right == left: right += 1\n else: sum_ -= line[left]\n\nprint(ans) ']
['Wrong Answer', 'Accepted']
['s897281795', 's476306810']
[39868.0, 41120.0]
[499.0, 462.0]
[659, 648]
p02623
u895231258
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['import numpy as np\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nA_np = np.array(A)\nB_np = np.array(B)\n\nC_np = np.append(A_np,B_np)\nC_np = np.sort(C_np)\n\nx = 0\nfor i in range(len(C_np)):\n if K > x + C_np[i]:\n x += 1\n else:\n break\nprint(x)', 'import numpy as np\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nA_np = np.array(A)\nB_np = np.array(B)\n\nC_np = np.append(A_np,B_np)\nC_np = np.sort(C_np)\n\nx = 0\ny = 0\nfor i in range(len(C_np)):\n if K >= x + C_np[i]:\n x += C_np[i]\n y += 1\n else:\n break\nprint(x)', '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)', 'import numpy as np\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nA_np = np.array(A)\nB_np = np.array(B)\n\nC_np = np.append(A_np,B_np)\nC_np = np.sort(C_np)\nprint(C_np)\nx = 0\nfor i in range(len(C_np)):\n if K >= x + C_np[i]:\n x += C_np[i]\n y += 1\n else:\n break\nprint(y)', 'import numpy as np\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nA_np = np.array(A)\nB_np = np.array(B)\n\ny=0\nfor i in range(N+M):\n if K >= min(A_np[0],B_np[0]):\n if A_np[0] < B_np[0]:\n K -= A_np[0]\n np.delete(A_np,0)\n y+=1\n else:\n K -= B_np[0]\n np.delete(B_np,0)\n y+=1\nprint(y)', 'import numpy as np\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nA_np = np.array(A)\nB_np = np.array(B)\n\nC_np = np.append(A_np,B_np)\nC_np = np.sort(C_np)\n\nx = 0\nfor i in range(len(C_np)):\n if K >= x + C_np[i]:\n x += 1\n else:\n break\nprint(x)', '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', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s014229069', 's069637238', 's077770856', 's136905870', 's477870491', 's808575050', 's288935598']
[58604.0, 58624.0, 47544.0, 58620.0, 58548.0, 58792.0, 47528.0]
[474.0, 490.0, 196.0, 271.0, 2207.0, 488.0, 282.0]
[316, 344, 374, 349, 417, 317, 366]
p02623
u896741788
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()))\nfrom itertools import accumulate\nar=[0]+list(accumulate(a))\nbru=[0]+list(accumulate(b))\nfrom bisect import bisect_left as bl,bisect_right as br\nans=0\nprint(ar,bru)\nfor i in range(n+1):\n g=ar[i]\n if g>k:break\n if k-g>=bru[-1]:ans=max(ans,i+m);continue\n j=bl(bru,k-g)\n ans=max(ans,i+j-1)\n\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nfrom itertools import accumulate\nar=[0]+list(accumulate(a))\nbru=[0]+list(accumulate(b))\nfrom bisect import bisect_left as bl,bisect_right as br\nans=0\n\nfor i in range(n+1):\n g=ar[i]\n if g>k:break\n if k-g>=bru[-1]:ans=max(ans,i+m);continue\n j=br(bru,k-g)\n ans=max(ans,i+j-1)\n #print(i,j-1)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s514031466', 's601358239']
[58588.0, 50940.0]
[346.0, 313.0]
[409, 414]
p02623
u900968659
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()))\nsumbook,sumt,i,j=0,0,0,0\nwhile True:\n if i<=(n-1) and j<=(m-1):\n if a[i]>b[j]:\n sumt+=b[j]\n j+=1\n else:\n sumt+=a[i]\n i+=1\n elif i>(n-1) and j<=(m-1):\n sumt+=b[j]\n j+=1\n elif i<=(n-1) and j>(m-1):\n sumt+=a[i]\n i+=1\n\n\n if sumt>=k:\n sumbook+=1\n break\n sumbook+=1\nprint(sumbook)', '# -*- coding: utf-8 -*-\nn,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nasum,bsum=[0],[0]\n\nfor i in range(n):\n asum.append(asum[i]+a[i])\nfor i in range(m):\n bsum.append(bsum[i]+b[i])\n\nans,j=0,m\nfor i in range(n+1):\n if asum[i]>k:\n break\n while bsum[j]>k-asum[i]:\n j-=1\n ans=max(ans,i+j)\nprint(ans) ']
['Wrong Answer', 'Accepted']
['s820039575', 's871143300']
[42396.0, 47592.0]
[267.0, 283.0]
[592, 533]
p02623
u902544771
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\nC = [0]\nD = [0]\nfor a in A:\n C.append(C[-1] + a)\nfor b in B:\n D.append(D[-1] + b)\n\np = n\nfor i in range(n + 1):\n if C[i] > k:\n p = i - 1\n break\n\n_max = 0\nkeep = 0\nfor i in range(p, -1, -1):\n for j in range(keep, m + 1):\n if C[i] + D[j] > k:\n _max = i + j - 1\n keep = j\n break\nprint(_max)', 'n, m, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nC = [0]\nD = [0]\nfor a in A:\n C.append(C[-1] + a)\nfor b in B:\n D.append(D[-1] + b)\n\np = n\nfor i in range(n + 1):\n if C[i] > k:\n p = i - 1\n break\n\n_max = p\nkeep = 0\nfor i in range(p, -1, -1):\n for j in range(keep, m + 1):\n if C[i] + D[j] > k:\n keep = j - 1\n break\n elif _max < i + j:\n _max = i + j\n if j == m:\n break\nprint(_max)']
['Wrong Answer', 'Accepted']
['s615075159', 's972776264']
[48668.0, 47668.0]
[2206.0, 367.0]
[468, 524]
p02623
u903005414
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
["from bisect import bisect_left\nimport numpy as np\nN, M, K = map(int, input().split())\nA = np.array(list(map(int, input().split())))\nB = np.array(list(map(int, input().split())))\n\nif A.sum() + B.sum() <= K:\n print(N + M)\n exit()\n\ncumsum_A = [0] + A.cumsum()\ncumsum_B = [0] + B.cumsum()\nprint('cusmum_A', cumsum_A)\nprint('cusmum_B', cumsum_B)\n\nans = 0\nfor num_A, t in enumerate(cumsum_A, start=1):\n if t > K:\n continue\n if t == K:\n ans = max(ans, num_A)\n num_B = bisect_left(cumsum_B, K - t)\n \n ans = max(ans, num_A + num_B)\n\nfor num_B, t in enumerate(cumsum_B, start=1):\n if t <= K:\n ans = max(ans, num_B)\nprint(ans)\n", "from bisect import bisect_left\nimport numpy as np\nN, M, K = map(int, input().split())\nA = np.array(list(map(int, input().split())))\nB = np.array(list(map(int, input().split())))\n\nif A.sum() + B.sum() <= K:\n print(N + M)\n exit()\n\ncumsum_A = [0] + A.cumsum()\ncumsum_B = [0] + B.cumsum()\nprint('cusmum_A', cumsum_A)\nprint('cusmum_B', cumsum_B)\n\nans = 0\nfor num_A, t in enumerate(cumsum_A, start=1):\n if t > K:\n break\n if t == K:\n ans = max(ans, num_A)\n num_B = bisect_left(cumsum_B, K - t)\n \n ans = max(ans, num_A + num_B)\n\nfor num_B, t in enumerate(cumsum_B, start=1):\n if t <= K:\n ans = max(ans, num_B)\nprint(ans)\n", "import numpy as np\nfrom bisect import bisect_right\n\nN, M, K = map(int, input().split())\nA: np.ndarray = np.array([0] + list(map(int, input().split())))\nB: np.ndarray = np.array([0] + list(map(int, input().split())))\n\nif A.sum() + B.sum() <= K:\n print(N + M)\n exit()\n\nA_cumsum = A.cumsum()\nB_cumsum = B.cumsum()\n\n# print(f'{A_cumsum=}')\n# print(f'{B_cumsum=}')\n\nans = 0\nfor i in range(N + 1):\n A_time = A_cumsum[i]\n if A_time > K:\n continue\n j = bisect_right(B_cumsum, K - A_time) - 1\n ans = max(ans, i + j)\nprint(ans)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s456892741', 's816604077', 's983315534']
[53420.0, 53500.0, 53668.0]
[864.0, 849.0, 681.0]
[728, 725, 543]
p02623
u910632349
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()))\naa,bb=[0],[0]\nfor i in range(n):\n aa.append(aa[-1]+a[i])\nfor i in range(m):\n bb.append(bb[-1]+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=list(map(int,input().split()))\nb=list(map(int,input().split()))\naa,bb=[0],[0]\nfor i in range(n):\n aa.append(aa[-1]+a[i])\nfor i in range(m):\n bb.append(bb[-1]+b[i])\nans,j=0,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)']
['Runtime Error', 'Accepted']
['s507913507', 's212106093']
[47372.0, 47480.0]
[186.0, 282.0]
[330, 333]
p02623
u915764321
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nA=[0]\nfor i in range(n):\n A.append(a[i])\nB=[0]\nfor i in range(m):\n B.append(b[i])\nans=0\nj=m\nfor i in range(n+1):\n if A[i]>k:\n break\n while B[j]>(k-A[i]):\n j-=1\n ans=max(ans,i+j)\nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nA=[0]\nfor i in range(n):\n A.append(a[i])\nB=[0]\nfor i in range(m):\n B.append(b[i])\nans=0\nj=m\nfor i in range(n+1):\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=[0]\nfor i in range(n):\n A.append(A[i]+a[i])\nB=[0]\nfor i in range(m):\n B.append(B[i]+b[i])\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', 'Runtime Error', 'Accepted']
['s199721316', 's230957749', 's241194312']
[40512.0, 40604.0, 47480.0]
[254.0, 253.0, 288.0]
[298, 273, 308]
p02623
u918770092
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.insert(0, 0)\nb.insert(0, 0)\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]\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)']
['Wrong Answer', 'Accepted']
['s905728975', 's948344438']
[40616.0, 47412.0]
[207.0, 289.0]
[268, 341]
p02623
u920463220
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\ndef ss(s,a):\n nn=len(a)\n for i in range(nn):\n if a[i]>s:return i\n return nn\nn,m,s=map(int, stdin.readline().split());M=10**9+2\ndn=list(map(int, stdin.readline().split()))#+[M]\ndm=list(map(int, stdin.readline().split()))#+[M]\npn=[dn[0]];pm=[dm[0]]\nfor v in dn[1:]:\n pn+=[pn[-1]+v]\nfor v in dm[1:]:\n pm+=[pm[-1]+v]\np=ss(s,pn)\nq=ss(0 if p-1<0 else pn[p-1],pm)\npp=ss(s,pm)\nqq=ss(0 if pp-1<0 else pm[pp-1],pn)\nprint(max(p+q,pp+qq))\n\n'''cn=0;cm=0;cs=0\nfor v in dn:\n cs+=v\n if cn>=n-1 or cs>s:\n f=1;cs-=v\n for v1 in dm:\n cs+=v1\n if cs>s:\n f=0\n break\n cn+=1\n if f==0:break\n #print(v)\n cn+=1\ncs=0\nfor v in dm:\n cs+=v\n if cm>=m-1 or cs>s:\n f=1;cs-=v\n for v1 in dn:\n cs+=v1\n if cs>s:\n f=0\n break\n cm+=1\n if f==0:break\n cm+=1\nprint(max(cn,cm))'''", 'from sys import stdin,stdout\nimport bisect as bs\nn,m,s=map(int, stdin.readline().split())\ndn=list(map(int, stdin.readline().split()))\ndm=list(map(int, stdin.readline().split()))\npre=[dm[0]];s1=0\nfor v in dm[1:]:\n pre+=[pre[-1]+v]\nm=bs.bisect_right(pre,s)\nfor i in range(n):\n s1+=dn[i]\n if s-s1>=0:m=max(m,i+1+bs.bisect_right(pre,s-s1))\nprint(m)\n']
['Wrong Answer', 'Accepted']
['s821024908', 's579273996']
[49420.0, 39944.0]
[233.0, 299.0]
[974, 354]
p02623
u921156673
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()))\nassert len(A) == N\nassert len(B) == M\n\nimport numpy as np\ncumA = np.cumsum([0] + A)\ncumB = np.cumsum([0] + B)\nmaximum = 0\nfor maxA,timeA in enumerate(cumA):\n if timeA > K:\n break\n timeB = K - timeA\n maxB = np.sum(timeA + cumB <= K)\n maximum = max(maximum, maxA + maxB)\nprint(maximum)', '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): a.append(a[i] + A[i])\nfor i in range(M): b.append(b[i] + B[i])\nans,j=0,0\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] <= K - a[i]:\n j += 1\n ans = max(ans, i+j)\nprint(ans)', 'N , M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\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])\nans,j=0,0\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] <= K - a[i]:\n j += 1\n ans = max(ans, i+j-1)\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): a.append(a[i] + A[i])\nfor i in range(M): 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', 'Runtime Error', 'Runtime Error', 'Accepted']
['s059298531', 's731698379', 's917780836', 's440669216']
[48952.0, 47328.0, 47292.0, 47504.0]
[2207.0, 283.0, 279.0, 295.0]
[435, 326, 328, 325]
p02623
u923662841
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 = list(map(int, input().split()))\n B = list(map(int, input().split()))\n \n indb = M-1\n now = sum(B)\n count = M\n while now > K:\n now -= B[indb]\n count -= 1\n indb -= 1\n \n ans = count\n \n for a in A:\n count += 1\n now += a\n \n while now >K and indb >= 0:\n now -= B[indb]\n count -= 1\n indb -= 1\n \n if now <= K:\n if ans < count:\n ans = count\n print(ans)\n \n\nif __name __ == "__main__":\n main()', 'import bisect\nimport itertools\nN,M,K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nk = 0\nfor i in range(M):\n index = bisect.bisect_left(A,B[i],k+1)\n A.insert(index, B[i])\n k = index\nS = 0\nif K>= sum(A):\n print(N+M)\nelse:\n for d, j in enumerate(A):\n S += j\n if S >=K:\n print(d)', 'from itertools import accumulate\nfrom bisect import bisect_right\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0] + list(accumulate(A))\nb = [0] + list(accumulate(B))\n\nresult = 0\nfor i in range(N + 1):\n if a[i] > K:\n break\n j = bisect_right(b, K - a[i])\n result = max(result, i + j - 1)\nprint(result)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s219312244', 's536933682', 's091313935']
[9000.0, 41272.0, 50760.0]
[28.0, 2206.0, 273.0]
[600, 370, 384]
p02623
u924182136
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 copy\nN,M,K = map(int,input().split())\nA = [0]*N\nB = [0]*M\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = 0\nb = 0\n\ntmp = 0\nans = 0\n\n# if A[a] < B[b]:\n# if tmp <= K:\n# tmp += A[a]\n# ans += 1\n# a += 1\n# elif A[a] > B[b]:\n# if tmp <= K:\n# tmp += B[b]\n# ans += 1\n# b += 1\n# if a > len(A)-1 or b > len(B)-1:\n# break\nfa = False\nfb = False\n\nwhile len(A) > 0 or len(B) > 0:\n AA = copy.copy(A)\n BB = copy.copy(B)\n if len(AA) != 0:\n a = AA.pop(0)\n fa = True\n if len(BB) != 0:\n b = BB.pop(0)\n fb = True\n if fa and fb:\n if a<=b:\n tmp += a\n ans += 1\n A = AA\n else:\n tmp += b\n ans += 1\n B = BB\n else:\n if fa:\n tmp += a\n ans += 1\n A = AA\n if fb:\n tmp += b\n ans += 1\n B = BB\n\n if tmp > K:\n break\n fa = False\n fb = False\n \n print(tmp,A,B)\n \nif len(A)==0 and len(B)==0:\n print(ans)\nelse:\n print(ans-1)\n', 'N,M,K = map(int,input().split())\nA = [0]*N\nB = [0]*M\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nb = []\nb.append(0)\ntmp = 0\nfor i in range(M):\n b.append(tmp+B[i])\n tmp = tmp+B[i]\na = [0]\nfor i in range(N):\n a.append(a[i]+A[i])\n#print(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)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s008333906', 's203954977']
[161480.0, 47436.0]
[2392.0, 301.0]
[1187, 526]
p02623
u929217794
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(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\na_accum = [0] + list(accumulate(a))\nb_accum = [0] + list(accumulate(b))\n\nfor j in range(len(a_accum)):\n for i in range(len(b_accum)):\n t = a_accum[-(j+1)] + b_accum[-(i+1)]\n candi = (n-j) + (m-i)\n print(n-j, m-i, candi)\n if ans >= candi:\n break\n if t <= k:\n ans = candi\n break\n\nprint(ans)', 'from collections import deque\n\n# N, M, K = map(int, input().split())\n\n\nN, M, K = map(int, "3 4 1000000000".split())\nA = deque(map(int, "600000000 90 120".split()))\nB = deque(map(int, "800000000 150 80 150".split()))\n\nresult = 0\n\nwhile (A != deque() and K >= A[0]) or (B != deque() and K >= B[0]):\n a, b = 0, 0\n na, nb = 0, 0\n for i in A:\n if a+i <= K:\n a += i\n na += 1\n else:\n break\n for i in B:\n if b+i <= K:\n b += i\n nb += 1\n else:\n break\n\n\n if na > nb:\n result += 1\n na -= 1\n K -= A.popleft()\n elif na < nb:\n result += 1\n nb -= 1\n K -= B.popleft()\n elif na == nb:\n result += 1\n if A[0] <= B[0]:\n na -= 1\n K -= A.popleft()\n else:\n nb -= 1\n K -= B.popleft()\nprint(result)\n', 'from collections import deque\n\nN, M, K = map(int, input().split())\nA = deque(map(int, input().split()))\nB = deque(map(int, input().split()))\n\nresult = 0\n\na, b = 0, 0\nna, nb = 0, 0\nfor i in range(len(A)):\n if a+A[i] <= K:\n a += A[i]\n na += 1\n else:\n break\nfor i in range(len(B)):\n if b+B[i] <= K:\n b += B[i]\n nb += 1\n else:\n break\n\nwhile A != deque() and K >= A[0]:\n if na > nb:\n result += 1\n na -= 1\n K -= A.popleft()\n elif na == nb:\n result += 1\n if A[0] <= B[0]:\n na -= 1\n K -= A.popleft()\n\nwhile B != deque() and K >= B[0]:\n if na < nb:\n result += 1\n nb -= 1\n K -= B.popleft()\n elif na == nb:\n result += 1\n if A[0] > B[0]:\n nb -= 1\n K -= B.popleft()\n\nprint(result)\n', 'from itertools import accumulate\n\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\na_accum = [0] + list(accumulate(a))\nb_accum = [0] + list(accumulate(b))\n\nj = m\nfor i in range(n+1):\n while k < a_accum[i] + b_accum[j] and j >= 1:\n j -= 1\n if k >= a_accum[i] + b_accum[j] and ans < i + j:\n ans = i + j\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s354701203', 's518608212', 's675672001', 's455270848']
[82828.0, 9292.0, 39380.0, 49120.0]
[2261.0, 32.0, 2206.0, 238.0]
[470, 971, 848, 388]
p02623
u933929042
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 random\nn, m, k = map(int, input().split())\n\na_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\n\n\n# print(n,m,k)\n# print(a_list[0], b_list[0])\na_sum = [0]\nb_sum = [0]\nmax_a = 0\nmax_b = 0\nfor i in range(1, max(n+1, m+1)):\n if i < n+1:\n a_sum.append(a_sum[i-1] + a_list[i-1])\n if a_sum[i] < k:\n max_a = i\n if i < m+1:\n b_sum.append(b_sum[i-1] + b_list[i-1])\n\nmax_num = max_a\n# print(max_a)\nwhile max_a > -1:\n while max_b < m and b_sum[max_b] <= k-a_sum[max_a]:\n max_b += 1\n if max_num < max_a + max_b:\n max_num = max_a + max_b\n # print(max_a, max_b)\n max_a -= 1\n\nprint(max_num)\n', 'import random\nn, m, k = map(int, input().split())\n\na_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\n\n\n# print(n,m,k)\n# print(a_list[0], b_list[0])\na_sum = [0]\nb_sum = [0]\nfor i in range(1, max(n+1, m+1)):\n if i < n+1:\n a_sum.append(a_sum[i-1] + a_list[i-1])\n if i < m+1:\n b_sum.append(b_sum[i-1] + b_list[i-1])\n\nans = 0\nfor i in range(n+1):\n if a_sum[i] > k:\n break\n else:\n j = m\n while b_sum[j] <= k - a_sum[i]:\n j -= 1\n ans = max(ans, i+j)\n \nprint(ans)\n# print(n+m) ', 'import random\n\nn, m, k = random.randint(1, 200000), random.randint(1, 200000), random.randint(1, 10**9)\n# a_list = list(map(int, input().split()))\n# b_list = list(map(int, input().split()))\na_list = [random.randint(1, 10**3) for i in range(n)]\nb_list = [random.randint(1, 10**3) for i in range(m)]\n# print(n,m,k)\n# print(a_list[0], b_list[0])\na_sum = [a_list[0]]\nb_sum = [b_list[0]]\nmax_a = 0\nmax_b = 0\nfor i in range(1, max(n, m)):\n if i < n:\n a_sum.append(a_sum[i-1] + a_list[i])\n if a_sum[i] < k:\n max_a = i+1\n if i < m:\n b_sum.append(b_sum[i-1] + b_list[i])\n\nmax_num = 0\nmax_a += 1\nwhile max_a > 0:\n max_a -= 1\n while max_b < m and b_sum[max_b] <= k-a_sum[max_a-1]:\n max_b += 1\n if max_num < max_a + max_b:\n max_num = max_a + max_b\n\nprint(max_num)\n# print(n+m)\n', 'import random\nn, m, k = map(int, input().split())\n\na_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\n\n\n# print(n,m,k)\n# print(a_list[0], b_list[0])\na_sum = [0]\nb_sum = [0]\nmax_a = 0\nmax_b = 0\nfor i in range(1, max(n+1, m+1)):\n if i < n+1:\n a_sum.append(a_sum[i-1] + a_list[i-1])\n if a_sum[i] < k:\n max_a = i\n if i < m+1:\n b_sum.append(b_sum[i-1] + b_list[i-1])\n\nmax_num = max_a\n# print(max_a)\nwhile max_a > -1:\n while max_b < m and b_sum[max_b] <= k-a_sum[max_a]:\n max_b += 1\n if max_num < max_a + max_b:\n max_num = max_a + max_b\n print(max_a, max_b)\n max_a -= 1\n\nprint(max_num)\n', 'n, m, k = map(int, input().split())\na_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\na_index = 0\nb_index = 0\ncount = 0\n\nwhile k > 0:\n a_min = 1e10\n b_min = 1e10\n if a_index < len(a_list):\n a_min = a_list[a_index]\n if b_index < len(b_list):\n b_min = b_list[b_index]\n\n if a_min == 1e10 and b_min == 1e10:\n breaka\n elif a_min < b_min:\n count += 1\n k -= a_min\n a_index += 1\n else:\n count += 1\n k -= b_min\n b_index += 1\n\nprint(count)\n', 'import random\nn, m, k = map(int, input().split())\n\na_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\n\n\n# print(n,m,k)\n# print(a_list[0], b_list[0])\na_sum = [0]\nb_sum = [0]\nmax_a = 0\nfor i in range(1, max(n+1, m+1)):\n if i < n+1:\n a_sum.append(a_sum[i-1] + a_list[i-1])\n if a_sum[i] <= k:\n max_a = i\n if i < m+1:\n b_sum.append(b_sum[i-1] + b_list[i-1])\n\nans = 0\nj = m\nfor i in range(0, max_a+1):\n while b_sum[j] > k - a_sum[i]:\n j -= 1\n ans = max(ans, i+j)\n \nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s283107672', 's381070070', 's409106958', 's664588286', 's752208534', 's817374970']
[49172.0, 48860.0, 33360.0, 48864.0, 40584.0, 48916.0]
[349.0, 328.0, 1046.0, 382.0, 341.0, 326.0]
[883, 771, 863, 881, 546, 760]
p02623
u934529721
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\nt = 0\n\nfor i in range(m):\n t += b[i]\n\n\nj = m\nans = 0\n\nfor i in range(n+1):\n \n while j > 0 and t > k:\n j -= 1\n t -= b[i]\n \n \n if t > k:\n break\n\n ans = max(ans, i+j)\n \n \n if i == n:\n break\n \n \n t += a[i]\n\nprint(ans)\n\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\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\nans = 0\n\nj = M\n\nfor i in range(N + 1):\n \n if a[i] > K:\n break\n\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n \n \nprint(ans)\n']
['Runtime Error', 'Accepted']
['s912191449', 's321704452']
[40548.0, 47312.0]
[240.0, 287.0]
[582, 449]
p02623
u934788990
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 j in range(m):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Accepted']
['s930437280', 's169432220']
[32732.0, 47332.0]
[69.0, 279.0]
[360, 362]
p02623
u940426302
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\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 j -= 1\n ans = max(ans, i + j)\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n\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\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n \na, b = [0], [0]\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 if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s482652826', 's999835170', 's059428365']
[9048.0, 9060.0, 47540.0]
[24.0, 25.0, 285.0]
[351, 334, 359]
p02623
u944731949
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())\ntimes_a = list(map(int, input().split()))\ntimes_b = list(map(int, input().split()))\nread_time = 0\nread_time_a = [0]\nread_time_b = [0]\nfor i in range(len(times_a)):\n read_time_a.append(read_time_a[i]+times_a[i])\nfor i in range(len(times_b)):\n read_time_b.append(read_time_b[i]+times_b[i])\ncount = 0\nfor i in range(N+1):\n t = read_time_a[i]\n l = 0\n r = len(read_time_b)\n while l + 1 < r:\n c = (l + r) // 2\n if t + read_time_b[c] <= K:\n l = c\n else:\n r = c\n if read_time_a[i] + read_time_b[l] <= K:\n ans = max(ans, i + l)\nprint(ans)\n', 'N, M, K = map(int, input().split())\ntimes_a = list(map(int, input().split()))\ntimes_b = list(map(int, input().split()))\nread_time = 0\nread_time_a = [0]\nread_time_b = [0]\nfor i in range(N):\n read_time_a.append(read_time_a[i]+times_a[i])\nfor i in range(M):\n read_time_b.append(read_time_b[i]+times_b[i])\n\nans = 0\nfor a_count in range(N+1):\n if read_time_a[a_count] > K:\n continue\n a_read_time = read_time_a[a_count]\n max_b_count = 0\n r = len(read_time_b)\n \n \n while max_b_count + 1 < r:\n c = (max_b_count + r) // 2\n \n if a_read_time + read_time_b[c] <= K:\n max_b_count = c\n \n else:\n r = c\n \n ans = max(ans, a_count + max_b_count)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s664900245', 's170214444']
[47556.0, 47308.0]
[194.0, 1143.0]
[637, 1178]
p02623
u946517952
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.
['alen,blen,k = map(int,input().split())\nalist = list(map(int,input().split()))\nblist = list(map(int,input().split()))\nmax = 0\n\nbcount = blen\nwhile sum(blist[:bcount]) > k:\n bcount -= 1\n\nfor a in range(alen+1):\n acount = alen-a\n asum = sum(alist[:acount])\n while asum + sum(blist[:bcount+1]) > k:\n bcount -= 1\n if acount + bcount > max and asum + sum(blist[:bcount])<=k:\n max = acount + bcount\n\nprint(max)\n', 'alen,blen,k = map(int,input().split())\nalist = list(map(int,input().split()))\nblist = list(map(int,input().split()))\nmax = 0\n\nbcount = blen\nwhile sum(blist[:bcount]) > k:\n bcount -= 1\nif bcount != 0:\n bsum = sum(blist[:bcount])\nfor a in range(alen+1):\n acount = alen-a\n asum = sum(alist[:acount])\n if bcount != 0:\n while asum + bsum > k:\n bcount -= 1\n bsum -= blist[bcount-1]\n if acount + bcount > max and asum + sum(blist[:bcount])<=k:\n max = acount + bcount\n\nprint(max)\n', 'anum,bnum,acc = map(int,input().split())\nalist = list(map(int,input().split()))\nblist = list(map(int,input().split()))\n\nasum = [0]\nbsum = [0]\nans = 0\nfor i in range(anum):\n asum.append(asum[i]+alist[i])\nfor i in range(bnum):\n bsum.append(bsum[i]+blist[i])\n\nb = bnum\nfor a in range(anum+1):\n if asum[a] > acc:\n break\n while asum[a] + bsum[b] > acc:\n b -=1\n ans = max(ans,a+b)\n\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s167649650', 's183623378', 's013049929']
[40380.0, 42352.0, 47488.0]
[2206.0, 2206.0, 287.0]
[433, 526, 416]
p02623
u952968889
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()))\ncnt=0\n\nif k - min([a[0], b[0]]) < 0:\n print(0)\n exit()\n\nwhile k>0:\n if a[0] < b[0]:\n k -= a.pop(0)\n elif a[0] > b[0]:\n k -= b.pop(0)\n else:\n if a[1] < b[1]:\n k -= a.pop(0)\n else:\n k -= b.pop(0)\n cnt += 1\n\nprint(cnt)', 'from itertools import zip_longest, count, accumulate\nfrom bisect import bisect, bisect_left\n \ndef LIST(): return list(map(int, input().split()))\n \nn, m, k = map(int, input().split())\na = [0] + list(accumulate(LIST()))\nb = list(accumulate(LIST()))\n \nnum = 0\n \nfor i, a in enumerate(a):\n time_rest = k - a\n \n if time_rest < 0:\n continue\n \n num = max(num, i + bisect(b, time_rest))\n \nprint(num)\n']
['Runtime Error', 'Accepted']
['s244141457', 's107111935']
[40448.0, 45284.0]
[2206.0, 256.0]
[351, 414]
p02623
u953379577
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.
['\nn,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\n\nb = list(map(int,input().split()))\n\nx = [0]\n\ny = [0]\n\nfor i in range(n):\n x.append(x[i]+a[i])\n\nfor i in range(m):\n y.append(y[i]+b[i])\n\nans = 0\n\ncnt = m\n\nfor i in range(n+1):\n \n if x[i]<0:\n break\n \n while y[cnt]>k-x[i]:\n cnt -= 1\n \n ans = max(ans,cnt+i)\n \nprint(ans)', 'n,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\n\nb = list(map(int,input().split()))\n\nx = [0]\n\ny = [0]\n\nfor i in range(n):\n x.append(x[i]+a[i])\n\nfor i in range(m):\n y.append(y[i]+b[i])\n\nans = 0\n\ncnt = m\n\nfor i in range(n+1):\n \n if k-x[i]<0:\n break\n \n while y[cnt]>k-x[i]:\n cnt -= 1\n \n ans = max(ans,cnt+i)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s562633322', 's712956871']
[47692.0, 47676.0]
[325.0, 307.0]
[382, 383]
p02623
u954170646
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\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 if a[i] > K:\n break\n while b[j] > K - a[j]:\n \tj -= 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[j]:\n \tj -= 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[j]:\n \tj -= 1\n ans = max(ans, i+j)\nprint(ans)\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i]+A[i])\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[j]:\n \tj -= 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[j]:\n \tj -= 1\n ans = max(ans, i + j)\nprint(ans)\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split(\u200bN, 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 \tj -= 1\n ans = max(ans, i + j)\nprint(ans))))\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 \tj -= 1\n ans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n \nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s221924154', 's336263023', 's648684905', 's918414180', 's492954127']
[47448.0, 8944.0, 9076.0, 8972.0, 47536.0]
[297.0, 23.0, 25.0, 30.0, 285.0]
[331, 668, 680, 681, 346]
p02623
u955125992
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 c(x):\n if sb[x] + S <= k: return True\n else: return False\n\n\nn ,m ,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsa = []\nsb = []\n\nif a[0] <= k:\n sa.append(a[0])\n for i in range(1, n):\n if sa[i-1]+a[i] > k:\n break\n sa.append(sa[i-1]+a[i])\n\nif b[0] <= k:\n sb.append(b[0])\n for j in range(1, m):\n if sb[j-1]+b[j] > k:\n break\n sb.append(sb[j-1]+b[j])\n\nif len(sa) == 0:\n print(len(sb))\n exit()\n\nfor i in range(len(sa))[::-1]:\n mb = 0\n lb = len(sb)\n S = sa[i]\n if lb == 0 or S + sb[0] > k:\n print(len(sa))\n exit()\n \n while lb - mb > 1:\n mid = (mb+lb)//2\n if c(mid):\n mb = mid\n else:\n lb = mid\n ans = max(ans, i+1+lb)\n\nprint(ans)', 'def c(x):\n if sb[x] + S <= k: return True\n else: return False\n\n\nn ,m ,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsa = []\nsb = []\n\nif a[0] <= k:\n sa.append(a[0])\n for i in range(1, n):\n if sa[i-1]+a[i] > k:\n break\n sa.append(sa[i-1]+a[i])\n\nif b[0] <= k:\n sb.append(b[0])\n for j in range(1, m):\n if sb[j-1]+b[j] > k:\n break\n sb.append(sb[j-1]+b[j])\n\nif len(sa) == 0:\n print(len(sb))\n exit()\n\nfor i in range(len(sa))[::-1]:\n mb = 0\n lb = len(sb) - 1\n if len(sb) == 0 or sa[i] + sb[0] > k:\n print(len(sa))\n exit()\n \n while lb - mb > 1:\n mid = (mb+lb)//2\n if c(mid):\n mb = mid\n else:\n lb = mid\n ans = max(ans, i+1+lb)\n\nprint(ans)', 'n ,m ,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsa = [0]\nsb = [0]\n\nfor i in range(n):\n sa.append(sa[i]+a[i])\n\nfor i in range(m):\n sb.append(sb[i]+b[i])\n\nans = 0\nj = m\n\n\nfor i in in range(n+1):\n if sa[i] > k:\n break\n while sa[i]+sb[j] > k:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)', 'def c(x):\n if sb[x] + S <= k: return True\n else: return False\n\n\nn ,m ,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsa = []\nsb = []\n\nif a[0] <= k:\n sa.append(a[0])\n for i in range(1, n):\n if sa[i-1]+a[i] > k:\n break\n sa.append(sa[i-1]+a[i])\n\nif b[0] <= k:\n sb.append(b[0])\n for j in range(1, m):\n if sb[j-1]+b[j] > k:\n break\n sb.append(sb[j-1]+b[j])\n\nif len(sa) == 0:\n print(len(sb))\n sys.exit()\n\nfor i in range(len(sa))[::-1]:\n mb = 0\n lb = len(sb) - 1\n if len(sb) == 0 or sa[i] + sb[0] > k:\n print(len(sa))\n sys.exit()\n \n while lb - mb > 1:\n mid = (mb+lb)//2\n if c(mid):\n mb = mid\n else:\n lb = mid\n ans = max(ans, i+1+lb)\n\nprint(ans)', 'n ,m ,k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsa = [0]\nsb = [0]\n\nfor i in range(n):\n sa.append(sa[i]+a[i])\n\nfor i in range(m):\n sb.append(sb[i]+b[i])\n\nans = 0\nj = m\n\n\nfor i in range(n+1):\n if sa[i] > k:\n break\n while sa[i]+sb[j] > k:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s077870488', 's583783488', 's585148689', 's657106026', 's722569229']
[41348.0, 42700.0, 9056.0, 42688.0, 47484.0]
[257.0, 242.0, 25.0, 266.0, 287.0]
[834, 833, 385, 841, 382]
p02623
u959340534
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 = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\n\nans = 0\nai = 0\nbi = 0\nt = 0\nwhile t < k and (ai < len(A) or bi < len(B)):\n if ai < len(A) and bi < len(B):\n a = A[ai]\n b = B[bi]\n if a < b:\n ai += 1\n t += a\n if t =< k:\n ans += 1\n else:\n bi += 1\n t += b\n if t =< k:\n ans += 1\n elif ai < len(A):\n ai += 1\n t += A[ai]\n if t =< k:\n ans += 1\n else:\n bi += 1\n t += B[bi]\n if t =< k:\n ans += 1\nprint(ans)\n \n \n', 'n,m,k = map(int, input().split())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ncum_a = []\ncum_b = []\nc = 0\nfor a in A:\n c += a\n cum_a.append(c)\nc = 0\nfor b in B:\n c += b\n cum_b.append(b)\nans = 0\nfor i, a in enumerate(A):\n cnt = 0\n thresh = k-a\n for b in B:\n if b <= thresh:\n break\n cnt += 1\n cnt = len(B) - cnt\n if ans < cnt + i + 1:\n ans = cnt + i + 1\nprint(ans)\n ', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s069817383', 's797531011', 's142567371']
[9044.0, 40440.0, 47588.0]
[23.0, 2206.0, 293.0]
[557, 418, 343]
p02623
u961595602
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 -*-\nfrom sys import stdin\n\n# import numpy as np\nfrom itertools import accumulate\nfrom bisect import bisect_right\n\n# import sys\n\n\n\ndef _li():\n return list(map(int, stdin.readline().split()))\n\n\ndef _li_():\n return list(map(lambda x: int(x) - 1, stdin.readline().split()))\n\n\ndef _lf():\n return list(map(float, stdin.readline().split()))\n\n\ndef _ls():\n return stdin.readline().split()\n\n\ndef _i():\n return int(stdin.readline())\n\n\ndef _f():\n return float(stdin.readline())\n\n\ndef _s():\n return stdin.readline()[:-1]\n\n\ndef search(cum1, cum2, iter_max, limit):\n ans = 0\n for i in range(iter_max):\n if cum1[i] > limit:\n break\n cand = bisect_right(cum2, limit - cum1[i])\n ans = max(i + 1 + cand, ans)\n return ans\n\n\nN, M, K = _li()\nA_list = _li()\nB_list = _li()\n\ncum_a = list(accumulate(A_list))\ncum_b = list(accumulate(B_list))\n\nif cum_a[0] < cum_b[0]:\n print(search(cum_a, cum_b, N))\nelse:\n print(search(cum_b, cum_a, M))\n', '# -*- coding: utf-8 -*-\nfrom sys import stdin\n\nimport numpy as np\n\n# from itertools import accumulate\n# from bisect import bisect_right\n\n# import sys\n\n\n\ndef _li():\n return list(map(int, stdin.readline().split()))\n\n\ndef _li_():\n return list(map(lambda x: int(x) - 1, stdin.readline().split()))\n\n\ndef _lf():\n return list(map(float, stdin.readline().split()))\n\n\ndef _ls():\n return stdin.readline().split()\n\n\ndef _i():\n return int(stdin.readline())\n\n\ndef _f():\n return float(stdin.readline())\n\n\ndef _s():\n return stdin.readline()[:-1]\n\n\nN, M, K = _li()\nA_list = _li()\nB_list = _li()\n\n\n\ncum_a = np.cumsum([0] + A_list)\ncum_b = np.cumsum(B_list)\n#\n# ans = 0\n# for i, a in enumerate(cum_a):\n# if a > K:\n# cur = 0\n# else:\n# cur = i\n\n# ans = max(cur + cand, ans)\nans = 0\nfor i, a in enumerate(cum_a):\n if a > K:\n cur = 0\n else:\n cur = i\n cand = np.searchsorted(cum_b, K - a, side="right")\n ans = max(cur + cand, ans)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s364683935', 's741483441']
[47772.0, 59440.0]
[141.0, 819.0]
[1029, 1138]
p02623
u965377001
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):\na.append(a[i] + A[i])\nfor i in range(M):\nb.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\na[i] > K:\nbreak\nwhile b[j] > K - a[i]:\nj -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\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\ta[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, 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', 'Runtime Error', 'Accepted']
['s304591527', 's498493520', 's035886710']
[9044.0, 8876.0, 47420.0]
[24.0, 31.0, 300.0]
[323, 332, 336]
p02623
u967822229
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#include<algorithm>\n#include<iomanip>\n#include<utility>\n#include<iomanip>\n#include<map>\n\n#include<cmath>\n#include<cstdio>\n\n#define rep(i,n) for(int i=0; i<(n); ++i)\n#define pai 3.1415926535897932384\n\nusing namespace std;\nusing ll =long long;\nusing P = pair<int,int>;\n\n#define MAX_N 200001\n#define MAX_M 200001\n\nint N, M;\nint K = 0;\nint res = 0;\n\nint A[MAX_N];\nint B[MAX_M];\n\n\nint main(int argc, const char * argv[]) {\n\n cin >> N >> M >> K;\n \n rep(i, N){\n int a;\n cin >> a;\n if(i==0) A[i] = a;\n else A[i] = A[i-1] + a;\n }\n \n rep(i, M){\n int b;\n cin >> b;\n if(i==0) B[i] = b;\n else B[i] = B[i-1] + b;\n }\n \n int a=0;\n for(int i=0; i<N; i++){\n if(A[i]>K) continue;\n \n a=i+1;\n }\n int b=M;\n for(int j=M-1; j>=0; j--){\n if(B[j] <= K-A[a]){\n res = max(res, a+b);\n break;\n }\n b--;\n }\n \n cout << res << endl;\n \n return 0;\n}\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\nwhile b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\na_sum = [0]\nfor i in range(n):\n a_sum.append(a_sum[i] + a[i])\n\nb_sum = [0]\nfor i in range(m):\n b_sum.append(b_sum[i] + b[i])\nb_sum.append(10**20)\nans = 0\n\nfor i in range(n+1):\n t = a_sum[i]\n l = 0\n r = len(b_sum)\n \n while l+1<r:\n \n c = (l + r) // 2\n \n \n if t+b_sum[c]<=k:\n l = c\n \n \n else:\n r = c\n \n if a_sum[i]+b_sum[l]<=k:\n ans = max(ans,i+l)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s402567188', 's734591572', 's085140607']
[8968.0, 47540.0, 47644.0]
[28.0, 349.0, 1107.0]
[1039, 354, 978]
p02623
u967864815
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\nai = 0\nbi = 0\nans = 0\n\nfor _ in range(n+m):\n if ai < n and bi < m:\n break\n if ai < n:\n a = A[ai]\n else: \n a = 10e10\n if bi < m:\n b = B[bi]\n else:\n b = 10e10\n if a > b:\n k -= b\n bi += 1\n else:\n k -= a\n ai += 1\n if k < 0:\n break\n ans += 1\n\n\nprint(ans)\n\n ', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\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']
['s241460966', 's350572593']
[40560.0, 47372.0]
[120.0, 283.0]
[461, 362]
p02623
u968404618
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(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA = [0] + A\nA = list(accumulate(A))\n\nB = [0] + B\nB = list(accumulate(B))\n\nans = 0\nb_cnt = m\nfor a_cnt in range(n+1):\n if a_cnt > k: continue\n\n while A[a_cnt]+B[b_cnt] > k:\n b_cnt -= 1\n ans = max(ans, a_cnt+b_cnt)\n\nprint(ans)', 'from itertools import accumulate\n\nn, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA = [0] + A\nA = list(accumulate(A))\n\nB = [0] + B\nB = list(accumulate(B))\n\nans = 0\nb_cnt = m\nfor a_cnt in range(n+1):\n if A[a_cnt] > k: continue\n\n while A[a_cnt]+B[b_cnt] > k:\n b_cnt -= 1\n ans = max(ans, a_cnt+b_cnt)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s200504150', 's712372953']
[42396.0, 42336.0]
[251.0, 228.0]
[383, 386]
p02623
u969081133
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=0\nd=0\ne=0\nans=0\nwhile c<k:\n if c<n and (a[d]>b[e] or (a[d]==b[e] and a[d+1]>=b[e+1])):\n c+=b[e]\n e+=1\n ans+=1\n elif d<m:\n c+=a[d]\n d+=1\n ans+=1\n else:\n break\nif c==k:\n print(ans)\nelse:\n print(ans-1)', 'n,m,k=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=0\nd=0\ne=0\nans=0\nwhile c<=k:\n if a[d]>=b[e]:\n c+=b[e]\n e+=1\n ans+=1\n else:\n c+=a[d]\n d+=1\n ans+=1\nif c==k:\n print(ans)\nelse:\n print(ans-1)', 'n,m,k=int(input())\na=list(msp(int,input().split()))\nb=list(msp(int,input().split()))\nc=0\nd=0\ne=0\nans=0\nwhile c<=k:\n if a[d]>=b[e]:\n c+=b[e]\n e+=1\n ans+=1\n else:\n c+=a[d]\n d+=1\n ans+=1\nif c==k:\n print(ans)\nelse:\n print(ans-1)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=0\nd=0\ne=0\nans=0\nwhile c<=k:\n if c<n and (a[d]>b[e] or (a[d]==b[e] and a[d+1]>=b[e+1])):\n c+=b[e]\n e+=1\n ans+=1\n elif d<m:\n c+=a[d]\n d+=1\n ans+=1\n else:\n break\nif c==k:\n print(ans)\nelse:\n print(ans-1)', 'n, m, k = map(int, input().split())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\naa = [0]\nbb = [0]\n \nfor s in range(n):\n aa.append(aa[s] + a[s])\nfor s in range(m):\n bb.append(bb[s] + b[s]) \nans = 0\nj = m\n \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)\n \nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s196990967', 's320510798', 's514970531', 's646734397', 's036583782']
[40600.0, 9120.0, 9204.0, 40616.0, 47360.0]
[159.0, 27.0, 28.0, 162.0, 306.0]
[323, 246, 246, 324, 388]
p02623
u971124021
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n time += a[0]\n a.popleft()\n else:\n time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n #cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\nsa = deque([x for x in a])\nsb = deque([x for x in b])\nsa.append(10**9+1)\nsb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n time += a[0]\n a.popleft()\n else:\n time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n #cnt(a,b,time)\n\ncnt(sa,sb,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n time += a[0]\n a.popleft()\n else:\n time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\n#cnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nimport numpy as np\nimport bisect\na = np.cumsum(a)\nb = np.cumsum(b)\nans = 0\nr = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while a[i] + b[r] > k:\n r -= 1\n ans = max(ans, i+r)\nif i == 0:\n r = bisect.bisect_left(b, k)\n ans = max(ans, i+r)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nimport numpy as np\nimport bisect\na = np.cumsum(a)\nb = np.cumsum(b)\nans = 0\nr = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while a[i] + b[r] > k:\n r -= 1\n ans = max(ans, i+r)\n\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n #time += a[0]\n a.popleft()\n else:\n #time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n time += a[0]\n a.popleft()\n else:\n time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(a,b,0)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n \na = [0] * (n + 1)\nb = [0] * (m + 1)\nfor i in range(n):\n a[i + 1] = a[i] + a[i]\nfor i in range(m):\n b[i + 1] = b[i] + b[i]\nans = 0\nr = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while a[i] + b[r] > k:\n r -= 1\n ans = max(ans, i+r)\n\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n \n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n time += a[0]\n #a.popleft()\n else:\n time += b[0]\n #b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nimport numpy as np\nimport bisect\na = np.cumsum(a)\nb = np.cumsum(b)\nans = 0\nr = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while a[i] + b[r] > k:\n r -= 1\n ans = max(ans, i+r)\n\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n #time += a[0]\n a.popleft()\n else:\n #time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\nsa = deque([x for x in a])\nsb = deque([x for x in b])\nsa.append(10**9+1)\nsb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n #time += a[0]\n a.popleft()\n else:\n #time += b[0]\n b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(sa,sb,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nfrom collections import deque\na = deque([x for x in a])\nb = deque([x for x in b])\na.append(10**9+1)\nb.append(10**9+1)\nans = 0\ndef cnt(a,b,time):\n global ans\n #print(ans, time,a,b)\n if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):\n if a[0] < b[0]:\n time += a[0]\n #a.popleft()\n else:\n time += b[0]\n #b.popleft()\n if time <= k:\n ans += 1\n cnt(a,b,time)\n\ncnt(a,b,0)\nprint(ans)', 'n,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n \nimport numpy as np\na = [0] + a\nb = [0] + b\nsa = np.cumsum(a)\nsb = np.cumsum(b)\nans = 0\nr = m\nfor i in range(n+1):\n if sa[i] > k:\n break\n while sa[i] + sb[r] > k:\n r -= 1\n ans = max(ans, i+r)\n\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s050752840', 's206216029', 's248640477', 's338418668', 's428429083', 's469428239', 's481211903', 's555629702', 's627224499', 's627867142', 's632505440', 's649489969', 's671229215', 's700877327', 's895683364', 's947730734', 's600481173']
[40480.0, 40472.0, 9080.0, 40604.0, 45624.0, 45688.0, 42384.0, 40504.0, 159864.0, 40512.0, 40512.0, 40616.0, 45820.0, 40564.0, 40484.0, 40632.0, 47440.0]
[129.0, 124.0, 22.0, 123.0, 226.0, 229.0, 121.0, 133.0, 2139.0, 257.0, 126.0, 130.0, 265.0, 134.0, 142.0, 124.0, 549.0]
[385, 523, 586, 523, 369, 306, 227, 524, 510, 364, 423, 524, 306, 524, 530, 524, 322]
p02623
u971811058
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['from bisect import bisect_left, bisect_right, bisect\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na = [0]+a\nb = [0]+b+[1e9+10]\nans = 0\nfor i in range(1, len(a)):\n a[i]+=a[i-1]\nfor i in range(1, len(b)):\n b[i]+=b[i-1]\nfor i in range(n+1):\n if a[i]>k: break\n rim = k-a[i]\n sub = bisect_left(b, rim)\n if sub == n+1: sub = n\n elif b[sub] != rim: sub-=1\n cnt = i+sub\n print(cnt)\n if ans<cnt: ans = cnt\nprint(ans)', '# Begin Header {{{\nfrom math import gcd\nfrom collections import Counter, deque, defaultdict\nfrom heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge\nfrom bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort\nfrom itertools import accumulate, product, permutations, combinations, combinations_with_replacement\n# }}} End Header\n\nn, m, k = map(int, input().split())\nA = list(accumulate(map(int, input().split())))\nB = list(accumulate(map(int, input().split())))\nA=[0]+A\nB=[0]+B\nans = []\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))\n']
['Wrong Answer', 'Accepted']
['s838893830', 's471435546']
[40432.0, 46112.0]
[411.0, 251.0]
[500, 704]
p02623
u972036293
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n ', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\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[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()))\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s450051372', 's726011953', 's901745186']
[47508.0, 47704.0, 47616.0]
[283.0, 2207.0, 287.0]
[327, 327, 344]
p02623
u972991614
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()))\nif len(A)>len(B):\n A += [0]*(len(A)-len(B))\nelif len(B)>len(A):\n B += [0]*(len(B)-len(A))\nprint(A)\nprint(B)\ntime = 0\ncount = 0\ni = 0\nj = 0\ngoukei = 0\nwhile time <= K:\n if A[i]>=B[j]:\n time += B[j]\n if time <= K:\n j +=1\n count += 1\n elif A[i] < B[j]:\n time += A[i]\n if time <= K:\n i += 1\n count +=1\nprint(count)', '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\nmax_num = 0\nj = M\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\nfor i in range(N+1):\n if a[i] > K:\n break\n else:\n while b[j] > K - a[i]:\n j -=1\n if j <0:\n break\n if K>= a[i] + b[j]:\n ans = max(ans,i + j)\nprint(ans)\n ']
['Runtime Error', 'Accepted']
['s908139331', 's214067019']
[40432.0, 48700.0]
[214.0, 315.0]
[497, 457]
p02623
u978313283
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())\n2 A = list(map(int, input().split()))\n3 B = list(map(int, input().split()))\n4\n5 a,b=[0],[0]\n 6 for 7\n8 for 9\ni in range(N): a.append(a[i] + A[i]) i in range(M): b.append(b[i] + B[i])\n10\n11 ans,j=0,M\n12 for 13\n14\n15\ni in range(N + 1): ifa[i]>K:\nbreak\nwhile b[j] > K - a[i]:\nj -= 1\nans = max(ans, i + j)\n16\n17\n18 print(ans)', 'N,M,K = map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nSumA=[0 for _ in range(N+1)]\nSumB=[0 for _ in range(M+1)]\nfor i in range(1,N+1):\n SumA[i]=SumA[i-1]+A[i-1]\nfor i in range(1,M+1):\n SumB[i]=SumB[i-1]+B[i-1]\n\ndef binary_search(Time,IndexA):\n if Time>K:\n return 0 \n l=0\n r=M\n c=(l+r)//2\n while r-l>1:\n if Time+SumB[c]>K: r=c\n if Time+SumB[c]<=K: l=c\n c=(l+r)//2\n if Time+SumB[r]>K: IndexB=l\n else: IndexB=r\n NumOfBooks=IndexA+IndexB\n return NumOfBooks\n\nMaxNumOfBooks=0\nfor IndexA in range(N+1):\n NumOfBooks=binary_search(SumA[IndexA],IndexA)\n if MaxNumOfBooks<NumOfBooks: MaxNumOfBooks=NumOfBooks\nprint(MaxNumOfBooks)']
['Runtime Error', 'Accepted']
['s718140024', 's878269614']
[9004.0, 48660.0]
[26.0, 1044.0]
[358, 731]
p02623
u979591106
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\nn,m,k = map(int, stdin.readline().rstrip().split())\na = list(map(int, stdin.readline().rstrip().split()))\nb = list(map(int, stdin.readline().rstrip().split()))\n\nA = [0]\nB = [0]\nans,res = 0,0\nfor i in range(0, n):\n A.append(A[i]+a[i])\nfor i in range(0, m):\n B.append(B[i]+b[i])\n\ndef ans(A, B):\n for i in range(0, n + 1):\n j = 0\n while A[i] + B[j + 1] <= k:\n j += 1\n if j == len(B) - 1:\n break\n\n ans = max(ans, i + j)\n return ans\n\nif A[1] > k and B[1] > k:\n print(0)\nelse:\n res = ans(A, B)\n print(res)', 'from sys import stdin\n\nn, m, k = map(int, stdin.readline().rstrip().split())\n\na = list(map(int, stdin.readline().rstrip().split()))\nb = list(map(int, stdin.readline().rstrip().split()))\n\nA,B = [0],[0]\n\nfor i in range(n):\n A.append(A[i]+a[i])\n\nfor i in range(m):\n B.append(B[i]+b[i])\n\nans = 0\nj = m\nfor i in range(n + 1):\n if A[i] > k:\n break\n while A[i] > k- B[j]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s328970689', 's370090702']
[47376.0, 48576.0]
[220.0, 293.0]
[600, 437]
p02623
u981747421
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 getmax(x,y):\n if x>y:\n return x\n else:\n return y\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])\n\nans,j = 0,M\nfor i in range(N+1):\n if a[j]>K:\n break\n while b[j] > K-a[i]: \n j -=1\n ans = max(ans, i+j)\nprint(ans)', 'def getmax(x,y):\n if x>y:\n return x\n else:\n return y\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])\n\nans,j = 0,K\nfor i in range(N+1):\n if a[j]>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()))\nbooka = 0\nbookb = 0\nbooknum = 0\ntime = 0\nba=0\nbb=0\nlim = 0\nwhile True:\n if booka >= N:\n while time<=K and bookb<M:\n bb += 1\n time += B[bookb]\n bookb += 1\n break\n if bookb>=M:\n while time<=K and booka<N:\n ba += 1\n time += A[booka]\n booka += 1\n break\n if A[booka]<B[bookb]:\n if A[booka]+A[booka+1] > B[bookb]+B[bookb+1]:\n time += B[bookb]\n bookb += 1\n else:\n time += A[booka]\n booka += 1\n else:\n if A[booka]+A[booka+1] <= B[bookb]+B[bookb+1]:\n time += A[booka]\n booka += 1\n else:\n time += B[bookb]\n bookb += 1\n if time >K:\n break\n booknum += 1\n while (booka == N-1 or bookb == M-1) and time <= K:\n if A[booka]<B[bookb]:\n time += A[booka]\n booka += 1\n booknum += 1\n else:\n time += B[bookb]\n bookb += 1\n booknum += 1\nif time > K and (bb!=0 or ba!=0):\n booknum-=1\nbooknum += (ba+bb)\n\nprint(booknum)\n', 'C:\\Users\\ia\\Documents\\Python Scripts\\test.pydef getmax(x,y):\n if x>y:\n return x\n else:\n return y\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])\n\nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] > K-a[i]: \n j -=1\n ans = max(ans, i+j)\nprint(ans)\n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nbooka = 0\nbookb = 0\nbooknum = 0\ntime = 0\nba=0\nbb=0\nwhile True:\n if booka >= N:\n while time<=K and bookb<M:\n bb += 1\n time += B[bookb]\n bookb += 1\n break\n if bookb>=M:\n while time<=K and booka<N:\n ba += 1\n time += A[booka]\n booka += 1\n break\n if A[booka]<B[bookb]:\n time += A[booka]\n booka += 1\n else:\n time += B[bookb]\n bookb += 1\n if time >K:\n break\n booknum += 1\nif time != K:\n booknum-=1\nbooknum += (ba+bb)\nprint(booknum)\n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nbooka = 0\nbookb = 0\nbooknum = 0\ntime = 0\nba=0\nbb=0\nlim = 0\nwhile True:\n if booka >= N:\n while time<=K and bookb<M:\n bb += 1\n time += B[bookb]\n bookb += 1\n break\n if bookb>=M:\n while time<=K and booka<N:\n ba += 1\n time += A[booka]\n booka += 1\n break\n if A[booka]<B[bookb]:\n if A[booka]+A[booka+1] > B[bookb]+B[bookb+1]:\n time += B[bookb]\n bookb += 1\n else:\n time += A[booka]\n booka += 1\n else:\n if A[booka]+A[booka+1] <= B[bookb]+B[bookb+1]:\n time += A[booka]\n booka += 1\n else:\n time += B[bookb]\n bookb += 1\n if time >K:\n break\n booknum += 1\n while (booka == N-1 or bookb == M-1):\n if A[booka]<B[bookb]:\n time += A[booka]\n booka += 1\n if time > K:\n booknum += 1\n else:\n break\n else:\n time += B[bookb]\n bookb += 1\n if time > K:\n booknum += 1\n else:\n break\nif time > K and (bb!=0 or ba!=0):\n booknum-=1\nbooknum += (ba+bb)\n\nprint(booknum)\n', 'N = int(input())\nimport math\ndef getdiv(x):\n list = []\n for i in range(1,math.floor(math.sqrt(x))+1):\n if x%i==0 and (not i in list):\n list.append(i)\n if math.sqrt(x) == math.floor(math.sqrt(x)):\n return len(list)*2-1\n else:\n return len(list)*2\nnumlist = [0]\nfor i in range(1,N+1):\n numlist.append(i*getdiv(i))\nprint(sum(numlist))\n', 'def getmax(x,y):\n if x>y:\n return x\n else:\n return y\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])\n\nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] > K-a[i]: \n j -=1\n ans = max(ans, i+j)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s025949032', 's153972657', 's220931364', 's340408694', 's543192868', 's645303818', 's676446379', 's485695830']
[47676.0, 47316.0, 41796.0, 8996.0, 40516.0, 40388.0, 9204.0, 47444.0]
[286.0, 193.0, 333.0, 27.0, 212.0, 345.0, 26.0, 299.0]
[656, 657, 1218, 701, 678, 1342, 378, 657]
p02623
u981758672
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\nwhile b[j] > K - a[i]:\n j -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s105212038', 's851059348', 's391677112']
[47372.0, 47684.0, 47528.0]
[263.0, 257.0, 299.0]
[350, 358, 362]
p02623
u981760053
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.
['\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nmax=0\n\nA.insert(0, 0)\nA = numpy.cumsum(A)\nB.insert(0,0)\nB = numpy.cumsum(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\n ans=max(ans,i+j)\n\nprint(ans)', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na,b=[0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans,j=0,M\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', 'Accepted']
['s157631132', 's075243541']
[40644.0, 47680.0]
[111.0, 293.0]
[317, 340]
p02623
u984276646
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())\nINF = int(1e18)\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nA = A[:]\nB = B[:]\ni, j = 0, 0\nmcnt = 0\ntmp = M+1\nccnt = 0\nwhile tmp != 0:\n ccnt += 1\n tmp //= 2\nLA = [0 for _ in range(N+1)]\nLB = [0 for _ in range(M+1)]\nfor i in range(N):\n LA[i+1] = LA[i] + A[i]\nfor i in range(M):\n LB[i+1] = LB[i] + B[i]\nfor i in range(N+1):\n l, r = 0, M+1\n d = (l + r) // 2\n if LA[i] <= K:\n if LB[M] + LA[i] <= K:\n mcnt = max(i + M, mcnt)\n else:\n for j in range(ccnt + 1):\n if LB[d] + LA[i] <= K:\n l = d\n d = (l + r) // 2\n else:\n r = d\n d = (l + r) // 2\n print(d)\n mcnt = max(i + d, mcnt)\n else:\n break\nprint(mcnt)', 'N, M, K = map(int, input().split())\nINF = int(1e18)\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ni, j = 0, 0\nmcnt = 0\ntmp = M+1\nccnt = 0\nwhile tmp != 0:\n ccnt += 1\n tmp //= 2\nLA = [0 for _ in range(N+1)]\nLB = [0 for _ in range(M+1)]\nfor i in range(N):\n LA[i+1] = LA[i] + A[i]\nfor i in range(M):\n LB[i+1] = LB[i] + B[i]\nfor i in range(N+1):\n l, r = 0, M+1\n d = (l + r) // 2\n if LA[i] <= K:\n if LB[M] + LA[i] <= K:\n mcnt = max(i + M, mcnt)\n else:\n for j in range(ccnt + 1):\n if LB[d] + LA[i] <= K:\n l = d\n d = (l + r) // 2\n else:\n r = d\n d = (l + r) // 2\n mcnt = max(i + d, mcnt)\n else:\n break\nprint(mcnt)\n']
['Wrong Answer', 'Accepted']
['s634240963', 's727463025']
[47592.0, 47316.0]
[1281.0, 1190.0]
[745, 713]
p02623
u992541367
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.reverse()\nB.reverse()\n\nt = 0\ncnt = 0\nc1, c2 = A.pop(), B.pop()\nwhile True:\n \n if t >= K or (t + c1 > K and t + c2 > K):\n break\n\n\n if (t + c1 <= K and t + c2 <= K):\n l1 = [c1]\n sum_1 = c1\n for a in A[-1]:\n if t + a <= K:\n l1.append(a)\n sum_1 += a\n else:\n break\n l2 = [c2]\n sum_2 = c2\n for b in B[-1]:\n if t + b <= K:\n l2.append(b)\n sum_2 += b\n else:\n break\n \n if sum_1 <= sum_2:\n t += sum_1\n cnt += len(l1)\n for i in range(len(l1)-1):\n A.pop()\n c1 = A.pop() if bool(A) else 100000000000\n else:\n t += sum_2\n cnt += len(l2)\n for i in range(len(l2)-1):\n B.pop()\n c2 = B.pop() if bool(B) else 100000000000\n\n elif t + c1 <= K:\n \n t += c1\n cnt += 1\n c1 = A.pop() if bool(A) else 100000000000\n else:\n if t + c2 <= K:\n t += c2\n cnt += 1\n c2 = B.pop() if bool(B) else 100000000000\n\nprint(cnt)\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])\n \nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s626201485', 's941430043']
[39920.0, 47340.0]
[116.0, 308.0]
[1295, 366]
p02623
u995062424
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 = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0]\nb = [0]\naa = 0\nbb = 0\nfor i in A:\n aa += i\n a.append(aa)\nfor j in B:\n bb += j\n b.append(bb)\n\nans = 0\ncnt = 0\nlb = len(b)-1\nfor i in range(len(a)):\n cnt = a[i]\n if(cnt > K):\n break\n for j in reversed(range(lb)):\n tmp = cnt + b[j]\n if(tmp > K):\n lb = j\n else:\n ans = max(i+j, ans)\n break\n\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0]\nb = [0]\naa = 0\nbb = 0\nfor i in A:\n aa += i\n a.append(aa)\nfor j in B:\n bb += j\n b.append(bb)\n\nans = 0\nlb = len(b)\nj = len(b)-1\nfor i in range(len(a)):\n if(a[i] > K):\n break\n while(a[i]+b[j] > K):\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s845844927', 's320093691']
[32956.0, 47508.0]
[104.0, 267.0]
[460, 387]
p02623
u995163736
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.
[' \na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor j in range(m):\n b.append(b[j]+B[j])\n#print(a,b)\n \nans = 0\nj = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while (k - a[i]) < b[j]:\n j -= 1\n if j == -1:\n break\n \n ans = max(ans, i+j)\n \nprint(ans)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n \na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor j in range(m):\n b.append(b[j]+B[j])\n#print(a,b)\n \nans = 0\nj = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while (k - a[i]) < b[j]:\n j -= 1\n if j == -1:\n break\n \n ans = max(ans, i+j)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s280257187', 's951555473']
[8924.0, 47612.0]
[24.0, 284.0]
[281, 389]
p02623
u995308690
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 math\nimport copy\n\n\n\n# n = int(input())\n\ntarget_1 = [int(x) for x in input().split()]\n\nN = target_1[0]\nM = target_1[1]\nK = target_1[2]\n\ntarget_2 = [int(x) for x in input().split()]\ntarget_2.reverse()\ntarget_3 = [int(x) for x in input().split()]\ntarget_3.reverse()\nresult = 0\n\nfor i in range(1, N + 1):\n \n left = K - sum(target_2[0:i])\n if left < 0:\n break\n result = max(result, i - 1)\n for j in range(1, M + 1):\n \n left_t = left - sum(target_3[0:j])\n if left_t < 0:\n break\n result = max(result, i + j)\n\n\nprint(result)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\n\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\n\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s430414046', 's439491286']
[39924.0, 47548.0]
[2206.0, 297.0]
[710, 365]
p02623
u996506712
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=[map(int,input().split())]\nb=[map(int,input().split())]\n\naa,bb=[0],[0]\nfor i in range(n):\n aa.append(aa[i]+a[i])\nfor i in range(m):\n bb.append(bb[i]+b[i])\nans,j=0,m\nfor i in range(n+1):\n if aa[i]>k:\n break\n while b[j]>k-aa[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\naa,bb=[0],[0]\nfor i in range(n):\n aa.append(aa[i]+a[i])\nfor i in range(m):\n bb.append(bb[i]+b[i])\nans,j=0,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)']
['Runtime Error', 'Accepted']
['s196983641', 's301070494']
[40460.0, 47600.0]
[65.0, 281.0]
[307, 318]
p02623
u999503965
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\ncount=0\ni,j=0,0\nwhile ans<k:\n if i > n-1:\n num=b[j]\n if j > m-1:\n num=a[i]\n else:\n num=min(a[i],b[j])\n if num==a[i]:\n i+=1\n count+=1\n ans+=num\n else:\n j+=1\n count+=1\n ans+=num\n \nprint(count)', 'n,m,k=3,4,730\na=[60,90,120]\nb=[80,150,80,150]\n\nans=0\ncount=0\ni,j=0,0\nif a[i]>k:\n print(0)\n exit()\nelif b[j]>k:\n print(0)\n exit()\nelif sum(a)+sum(b)<=k:\n print(n+m)\n exit()\nelse:\n while ans<=k:\n if i > n-1:\n num=b[j]\n elif j > m-1:\n num=a[i]\n else:\n num=min(a[i],b[j])\n if num==a[i]:\n i+=1\n count+=1\n ans+=num\n else:\n j+=1\n count+=1\n ans+=num\n\nif num==k:\n print(count)\nelse:\n print(count-1)\n', 'n,m,k=map(int,input().split())\nA=[0]+list(map(int,input().split()))\nB=[0]+list(map(int,input().split()))\n\nfor a in A:\n A[a]+=A[a+1]\n \nfor b in B:\n B[b]+=B[b+1]\n\nans=0\nop=m\nfor i in range(n+1):\n if A[i]>k:\n break\n while A[i]+B[op]>k:\n op-=1\n \n ans=max(ans,i+op)\n \nprint(ans)\n', 'n,m,k=map(int,input().split())\nA=[0]+list(map(int,input().split()))\nB=[0]+list(map(int,input().split()))\n\nasum=[0]\nbsum=[0]\n\nfor i in range(n):\n asum.append(asum[i]+A[i])\n \nfor j in range(m):\n bsum.append(bsum[j]+B[j])\n\nans=0\nko=m\nfor i in range(n+1):\n if asum[i]>k:\n break\n while asum[i]+bsum[ko]>k:\n ko-=1\n ans=max(ans,i+ko)\n \nprint(ans)\n', 'n,m,k=map(int,input().split())\nA=[0]+list(map(int,input().split()))\nB=[0]+list(map(int,input().split()))\n\nfor a in A:\n A[a]+=A[a+1]\n \nfor b in B:\n B[b]+=B[b+1]\n\nans=0\nop=m\nfor i in range(n+1):\n while A[i]+B[op]>k:\n op-=1\n \n ans=max(ans,i+op)\n \nprint(ans)', 'n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nasum=[0]\nbsum=[0]\n\nfor i in range(n):\n asum.append(asum[i]+A[i])\n \nfor j in range(m):\n bsum.append(bsum[j]+B[j])\n\nans=0\nko=m\nfor i in range(n+1):\n if asum[i]>k:\n break\n while asum[i]+bsum[ko]>k:\n ko-=1\n ans=max(ans,i+ko)\n \nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s077193804', 's486594282', 's632478125', 's819152188', 's879612212', 's115906395']
[40680.0, 8928.0, 39812.0, 47444.0, 39956.0, 47508.0]
[2206.0, 31.0, 188.0, 308.0, 250.0, 311.0]
[343, 475, 289, 353, 265, 345]
p02623
u999799597
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(v) for v in input().split()]\nb = [int(v) for v in input().split()]\nans = []\nfor _ in range(n + m):\n if len(a) > 0 and len(b) > 0 and a[0] <= b[0] and a[0] <= k:\n k -= a[0]\n ans.append(a[0])\n a.pop(0)\n elif len(a) > 0 and len(b) > 0 and b[0] <= a[0] and b[0] <= k:\n k -= b[0]\n ans.append(b[0])\n b.pop(0)\n elif len(a) == 0 and len(b) > 0 and b[0] <= k:\n k -= b[0]\n ans.append(b[0])\n b.pop(0)\n elif len(b) == 0 and len(a) > 0 and a[0] <= k:\n k -= a[0]\n ans.append(a[0])\n a.pop(0)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\n\nfor i in range(m):\n b.append(b[i] + B[i])\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']
['s414372516', 's450494415']
[40544.0, 47364.0]
[2206.0, 284.0]
[617, 362]
p02624
u000037600
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['print(www)', 'a=int(input())\nans=0\nfor i in range(a):\n x=a//i\n ans+=((a+1)a)/2\nprint(ans)', 'import math\na=int(input())\nb=list(i+1 for i in range(a))\nwww=0\nfor j in b:\n c=[x+1 for x in range(int(math.sqrt(j)//1))]\n for y in c:\n if j%y==0:\n if not j==y*y:\n www=+j*2\n else:\n www+=j\nprint(www)', 'import math\na=int(input())\nb=list(i+1 for i in range(a))\nwww=0\nfor j in b:\n c=[x+1 for x in range(int(math.sqrt(j)//1))]\n for y in c:\n if j%y==0:\n if not j/y==y:\n www=+j*2\n else:\n www+=j\nprint(www)', 'a=int(input())\nb=(a)//2+1\nans=0\nfor i in range(1,b,1):\n x=a//i\n ans+=((x**2+x)//2)*i\nans+=(a**2+a+b-b**2)//2\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s105864483', 's137631050', 's469735135', 's747393352', 's237972900']
[8880.0, 9012.0, 404696.0, 404752.0, 9108.0]
[29.0, 27.0, 3327.0, 3326.0, 2238.0]
[10, 77, 226, 226, 121]
p02624
u007074599
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n=int(imput())\n\nans=0\nfor i in range(n):\n i=i+1\n a=i\n y=n//i\n\n ans+=(i*y*(y+1)/2)\n\n\n\nprint(ans)', 'n=int(input())\n \nans=0\nfor i in range(n):\n i=i+1\n a=i\n y=n//i\n \n ans+=(i*y*(y+1)/2)\n \n \n \nprint(int(ans))']
['Runtime Error', 'Accepted']
['s496715997', 's816913548']
[9088.0, 9164.0]
[23.0, 2823.0]
[99, 109]
p02624
u021114240
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['import math\nimport time\nfrom collections import defaultdict,deque\nfrom sys import stdin,stdout\nfrom bisect import bisect_left,bisect_right\nn=int(input())\ns=time.time()\nfactors=defaultdict(lambda:[])\nfor i in range(2,3300):\n if(i not in factors):\n for j in range(i,10000001,i):\n factors[j].append(i)\nans=1\n# print(factors)\n# print(time.time()-s)\nfor i in range(2,n+1):\n tt=1\n tn=i\n for j in factors[i]:\n temp=0\n while(tn%j==0):\n temp+=1\n tn=tn//j\n tt*=(temp+1)\n if(tn!=1):\n tt*=2\n ans+=i*tt\nprint(ans)\n# print(time.time()-s)\n\n\n\n', 'import math\nimport time\nfrom collections import defaultdict,deque\nfrom sys import stdin,stdout\nfrom bisect import bisect_left,bisect_right\ndef find(a):\n return (a*(a+1))//2\nn=int(input())\nans=0\nfor i in range(1,n+1):\n ans+=i*find(n//i)\nprint(ans)\n\n\n\n']
['Time Limit Exceeded', 'Accepted']
['s314242101', 's761082327']
[735680.0, 9484.0]
[3336.0, 2711.0]
[613, 256]
p02624
u047197186
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['def solve(n):\n ans = 0\n for i in range(1,n+1):\n y = n//i\n print(y)\n ans += (y*(y+1)*i)/2\n return ans\n\ndef main():\n n = int(input())\n print(int(solve(n)))\n\nif __name__ == "__main__":\n main()\n', 'def solve(n):\n ans = 0\n for i in range(1,n+1):\n y = n//i\n ans += (y*(y+1)*i)/2\n return ans\n\ndef main():\n n = int(input())\n print(int(solve(n)))\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s885880918', 's767512191']
[21920.0, 9116.0]
[3332.0, 1122.0]
[229, 211]
p02624
u052244548
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['import itertools\nimport functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\ndef main_chk():\n N = int(input())\n\n ans = 0\n for i in range(1,N+1):\n m = N // i\n ans += ( m + 1 ) * m * i / 2\n\n print(ans)\nmain_chk()\n', 'import itertools\nimport functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\ndef main_chk():\n N = int(input())\n\n ans = 0\n for i in range(1,N+1):\n m = N // i\n ans += ( m + 1 ) * m * i / 2\n\n print(math.floor(ans))\nmain_chk()\n']
['Wrong Answer', 'Accepted']
['s962554935', 's773553790']
[9884.0, 9884.0]
[1136.0, 1137.0]
[285, 297]
p02624
u054798759
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n = int(input())\nans = 0\nfor i in range(1,n+1):\n ans += i * (1+n//i) * (n//i) / 2\nprint(ans)', 'primes = [2]\nli = [[],[]]\nf_ans = [0]\ndef f(x):\n if x==1:\n f_ans.append(1)\n return 1\n if x==2:\n f_ans.append(2)\n return 2\n flag = True\n for i in range(len(primes)):\n if x%primes[i]==0:\n tmp = li[x//primes[i]][:]\n tmp[i] += 1\n li.append(tmp)\n f_ans.append(f_ans[x//primes[i]]//tmp[i]*(tmp[i]+1))\n return f_ans(x)\n else:\n li.append([0]*len(primes)+[1])\n f_ans.append(2)\n primes.append(x)\n return 2\n\nn = int(input())\nsum = 0\nfor i in range(1,n+1):\n sum += i * f(i)\nprint(sum)', 'n = int(input())\nans = 0\nfor i in range(1,n+1):\n ans += i * (1+n//i) * (n//i) // 2\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s360946939', 's416742884', 's943882045']
[9096.0, 9076.0, 9040.0]
[2315.0, 30.0, 2505.0]
[93, 540, 95]
p02624
u065578867
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['N = int(input())\nans = 0\nans += N*(N+1)/2\n\nfor i in range(2, N+1):\n N_case = N // i\n ans += N_case*(N_case + 1)*i//2\n\nprint(ans)\n', 'N = int(input())\nans = 0\nans += N*(N+1)//2\n\nif N >= 2:\n for i in range(2, N+1):\n N_case = N // i\n ans += N_case*(N_case + 1)*i//2\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s509731086', 's319952290']
[9160.0, 8980.0]
[2327.0, 2447.0]
[135, 159]
p02624
u066494348
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n=int(input())\nans=0\nfor i in range(1,n+1):\n\tx=math.floor(n/i)\n\tans+=(x*(x+1)*i)/2\nprint(int(ans))', 'import math\nn=int(input())\nans=0\nfor i in range(1,n+1):\n\tx=math.floor(n/i)\n\tans+=(x*(x+1)*i)/2\nprint(int(ans))']
['Runtime Error', 'Accepted']
['s512801805', 's531921854']
[9076.0, 9012.0]
[23.0, 2960.0]
[98, 110]
p02624
u066551652
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['def divisors(n):\n i = 1\n cnt = 0\n while i*i <= n:\n if n % i == 0:\n cnt += 1\n if i * i != n:\n cnt += 1\n i += 1\n return cnt\n\nn = int(input())\nans = 0\nfor i in range(1, n + 1):\n ans += i * divisors(i)', 'def cal(b, e):\n return ((b + (e//b) * b) * (e//b))//2\n\nn = int(input())\nans = 0\n\nfor i in range(1, n+1):\n ans += cal(i, n)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s445728800', 's212106696']
[9040.0, 9164.0]
[3308.0, 2736.0]
[263, 140]
p02624
u072284094
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n = int(input())\n\nresult = 0\nfor i in range(1,(n // 2 + 1)):\n terms = n // i\n result += terms * (terms * i + i) // 2\n\nterms = n - n // 2\nresult += terms * (n // 2 + n) // 2\n\nprint(result)', 'n = int(input())\n\nresult = 0\nfor i in range(1,(n // 2 + 1)):\n terms = n // i\n result += terms * (terms * i + i) // 2\n\nterms = n - n // 2\nresult += terms * (n // 2 + 1 + n) // 2\n\nprint(result)']
['Wrong Answer', 'Accepted']
['s751182611', 's357485291']
[9176.0, 9172.0]
[1345.0, 1304.0]
[193, 197]
p02624
u072409340
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['N = int(input())\na=0\nfor i in range(1,n+1):\n x,y=i,(n//i)*i\n a+=((n//i)*(x+y)//2)\nprint(a)', 'n=int(input())\nans=0\nfor i in range(1,n+1):\n x,y=i,(n//i)*i\n ans+=((n//i)*(x+y)//2)\nprint(ans)']
['Runtime Error', 'Accepted']
['s652448778', 's093445738']
[9148.0, 9112.0]
[27.0, 2985.0]
[92, 100]
p02624
u077291787
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['# D - Sum of Divisors\nfrom numba import njit\n\n\n@njit\ndef main():\n N = int(input())\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 print(res)\n\n\nif __name__ == "__main__":\n main()\n', '# 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']
['Runtime Error', 'Accepted']
['s317956629', 's417059936']
[106600.0, 108948.0]
[467.0, 672.0]
[247, 283]
p02624
u091307273
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['def main():\n N = int(input())\n tot = 0\n for d in range(1, N+1):\n nd = N//d\n tot += (d * (nd + 1) * nd) // 2\n\n print(tot)\n\n', 'N = int(input())\ntot = 0\nfor d in range(1, N+1):\n nd = N//d\n tot += (d * (nd + 1) * nd) // 2\n\nprint(tot)\n\n\n']
['Wrong Answer', 'Accepted']
['s420899635', 's717582249']
[9048.0, 8972.0]
[27.0, 2451.0]
[148, 113]
p02624
u102461423
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['import sys\nimport numba\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\[email protected]\ndef main(N):\n x = 0\n for a in range(1, N+1):\n for b in range(1, N//a+1):\n x += a*b\n return x\n\nfrom my_module import main\n\nN = int(read())\nprint(main(N))\n', "import sys\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\ndef main(N):\n div = np.zeros(N+1, np.int64)\n for n in range(1, N+1):\n div[::n] += 1\n div *= np.arange(N + 1)\n return div.sum()\n\nif sys.argv[-1] == 'ONLINE_JUDGE':\n import numba\n from numba.pycc import CC\n i8 = numba.int64\n cc = CC('my_module')\n\n def cc_export(f, signature):\n cc.export(f.__name__, signature)(f)\n return numba.njit(f)\n\n main = cc_export(main, (i8, ))\n cc.compile()\n\nfrom my_module import main\n\nN = int(read())\nprint(main(N))\n", "import sys\nimport numba\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\[email protected]('(i8,)', cache=True)\ndef main(N):\n x = 0\n for a in range(1, N+1):\n for b in range(1, N//a+1):\n x += a*b\n return x\n\nN = int(read())\nprint(main(N))\n"]
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s272069674', 's888950289', 's819915157']
[91780.0, 183004.0, 106264.0]
[370.0, 3312.0, 531.0]
[323, 630, 316]
p02624
u116038906
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['\ndef make_divisors(n): をリストで返す\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n \n return divisors\n\n\nimport sys\ninput = sys.stdin.readline\nN = int(input())\n\n#DP\nf_dp =[0]*(N+1)\n\nans =[]\nfor i in range(N,0,-1):\n if f_dp[i] ==0:\n f =make_divisors(i)\n f.sort(reverse=True)\n f_dp[i] =len(f)\n for j in range(len(f)-1):\n f_dp[f[j+1]] =f_dp[f[j]]-1\n ans.append(i *f_dp[i])\nprint(sum(ans))', '#https://www.youtube.com/watch?v=3gFnZhZlAF8\n\n\n\nimport sys\ninput = sys.stdin.readline\nN = int(input())\nans =0\nfor i in range(1,N+1):\n n =N//i \n ans +=n*(2*i +(n-1)*i)//2\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s066759290', 's183572735']
[87936.0, 9092.0]
[3311.0, 2956.0]
[685, 289]
p02624
u125348436
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n=int(input())\ndef make_divisors(n):\n lower_divisors = []\n upper_divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n\n upper_divisors.reverse()\n return n+len(lower_divisors + upper_divisors)\nsumi=0\nfor i in range(1,n+1):\n sumi+=make_divisors(i)\nprint(sumi)', 'n=int(input())\nans=0\nfor i in range(n):\n y=n//i\n ans+=y*(y+1)*i//2\nprint(ans)', 'n=int(input())\nans=0\nfor i in range(1,n+1):\n y=n//i\n ans+=y*(y+1)*i//2\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s388944860', 's392924570', 's235005312']
[9448.0, 9036.0, 9168.0]
[3308.0, 24.0, 2258.0]
[403, 79, 83]
p02624
u136843617
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['import numpy as np\nfrom numba import njit\n\n\n@njit(\'(i8)\', cache=True)\ndef solve(x):\n count = np.zeros(x + 1, dtype=np.int64)\n for i in range(1, x + 1):\n for j in range(i, x + 1, i):\n count[j] += j\n return count.sum()\n\n\nif __name__ == "__main__":\n x = int(input())\n print(solve(x))\n\n', 'import numpy as np\nfrom numba import njit\n \n@njit(\'i8(i8)\', cache=True)\ndef solve(x):\n count = np.ones(x + 1, dtype=np.int8)\n for i in range(2,x+1):\n for j in range(i,x+1,i)\n count[j] += 1\n return int(np.sum(np.arange(x + 1) * count))\n \nif __name__== "__main__":\n x = int(input())\n print(solve(x))', 'import numpy as np\nfrom numba import njit\n\n\n@njit(\'i8(i8)\', cache=True)\ndef solve(x):\n count = np.zeros(x + 1, dtype=np.int64)\n for i in range(1, x + 1):\n for j in range(i, x + 1, i):\n count[j] += j\n return count.sum()\n\n\nif __name__ == "__main__":\n x = int(input())\n print(solve(x))\n\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s668236660', 's756325374', 's115383802']
[91852.0, 8908.0, 184396.0]
[368.0, 31.0, 1725.0]
[315, 330, 317]
p02624
u167908302
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['# coding:utf-8\nimport sympy\nn = int(input())\n\nans = 0\nfor i in range(1, n + 1):\n ans += i * sympy.divisors(i)\nprint(ans)\n', '# coding:utf-8\nn = int(input())\nans = 0\n\nfor i in range(1, n + 1):\n tmp = n // i\n ans += i * tmp * (tmp + 1) // 2\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s327646740', 's950683954']
[8796.0, 9056.0]
[27.0, 2495.0]
[124, 131]
p02624
u168030064
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n = int(input())\n\nans = 0\nfor x in range(1, n + 1):\n ans += (x + n//x * x) * (n // x) / 2\n \nprint(ans)', 'n = int(input())\n\nans = 0\nfor x in range(1, n + 1):\n ans += (x + n//x * x) * (n // x) / 2\n \nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s984628058', 's715215677']
[9088.0, 9024.0]
[2285.0, 2577.0]
[108, 113]
p02624
u180172332
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['import numpy as np\ndef divisor_num(n):\n if n == 1:\n return 1\n arr = []\n temp = n\n for i in range(2,int(np.sqrt(n))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append(cnt)\n \n if temp!=1:\n arr.append(1)\n\n if arr==[]:\n arr.append(1)\n \n ans = 1\n for num in arr:\n ans *= num+1\n \n return ans\n\nn = int(input())\ntotal = 0\nfor i in range(1,n+1):\n total += i*divisor_num(i)\n', 'import numpy as np\ndef divisor_num(n):\n if n == 1:\n return 1\n arr = []\n temp = n\n for i in range(2,int(np.sqrt(n))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append(cnt)\n \n if temp!=1:\n arr.append(1)\n\n if arr==[]:\n arr.append(1)\n \n ans = 1\n for num in arr:\n ans *= num+1\n \n return ans\n\nn = int(input())\ntotal = 0\nfor i in range(1,n+1):\n total += i*divisor_num(i)', 'n = int(input())\n\nans = 0\nfor i in range(1,n+1):\n num = n//i\n ans += num*(i+i*num)//2\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s294157739', 's658726067', 's925139273']
[26984.0, 26944.0, 9020.0]
[3309.0, 3309.0, 2536.0]
[526, 525, 103]
p02624
u192165179
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['N = int(input())\n\nt = 0\n\nfor i in range (1,N+1):\n p = N//i\n t += i*p*(1+p)/2\n \n\nprint(t)', 'N = int(input())\n\nt = 0\n\nfor i in range (1,N+1):\n p = N//i\n t += i*p*(1+p)/2\n \n\nprint(int(t))']
['Wrong Answer', 'Accepted']
['s111459483', 's474795065']
[9012.0, 9092.0]
[2208.0, 2145.0]
[91, 96]
p02624
u201544433
3,000
1,048,576
For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K).
['n = int(input().strip())\na = 0\nfor i in range(1, n+1):\n a += i*((n//i)*(n//i+1)//2)\n print(a)', 'n = int(input())\na = n * (n+1) // 2\nfor i in range(2, n+1):\n c = n // i\n a += i * (c * (c+1) // 2)\nprint(a)']
['Runtime Error', 'Accepted']
['s569127534', 's121418956']
[9024.0, 9156.0]
[29.0, 2611.0]
[94, 109]