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
u310709512
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\ntotalA = [0]\ntotalB = [0]\nsumA = 0\nfor i in range(N):\n sumA += A[0]\n totalA.append(sumA)\nsumB = 0\nfor i in range(M):\n sumB += B[0]\n totalB.append(sumB)\n\niA = N\niB = 0\ncountMax = 0\nwhile iA >= 0:\n if totalA[iA] + totalB[iB] > K:\n iA -= 1\n else:\n if iB < M:\n countMax = max(countMax, iA + iB)\n iB += 1\n elif iA == N and iB == M:\n countMax = max(countMax, iA + iB)\n break\n\nprint(countMax)\n\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ntotalA = [0]\ntotalB = [0]\nsumA = 0\nfor i in range(N):\n sumA += A[i]\n totalA.append(sumA)\nsumB = 0\nfor i in range(M):\n sumB += B[i]\n totalB.append(sumB)\n\niB = M\ncountMax = 0\nfor iA in range(N+1):\n if totalA[iA]>K:\n break\n else:\n while totalA[iA] + totalB[iB] > K:\n iB -= 1\n countMax = max(countMax,iA+iB)\n\nprint(countMax)\n\n']
['Runtime Error', 'Accepted']
['s352302446', 's547748760']
[8860.0, 47456.0]
[25.0, 282.0]
[567, 457]
p02623
u311379832
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\narui = [0] * (N + 1)\nbrui = [0] * (M + 1)\nfor i in range(N):\n arui.append(a[i] + arui[i])\nfor i in range(M):\n brui.append(b[i] + brui[i])\n\nans = 0\nfor i in range(N + 1):\n if arui[i] > K:\n break\n bcnt = M\n while brui[bcnt] + arui[i] > K:\n bcnt -= 1\n ans = max(ans, i + bcnt)\n\nprint(ans)', 'N, M, K = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\narui = [0] * (N + 1)\nbrui = [0] * (M + 1)\nfor i in range(N):\n arui[i + 1] = a[i] + arui[i]\nfor i in range(M):\n brui[i + 1] = b[i] + brui[i]\n\nans = 0\nbcnt = M\nfor i in range(N + 1):\n if arui[i] > K:\n break\n\n while brui[bcnt] + arui[i] > K:\n bcnt -= 1\n ans = max(ans, i + bcnt)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s401607950', 's937476151']
[48776.0, 47544.0]
[281.0, 300.0]
[425, 425]
p02623
u312078744
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['import itertools\nimport numpy as np \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\nacc = list(itertools.accumulate(a))\nbcc = list(itertools.accumulate(b))\n\nacc = np.array(acc)\n#print(acc)\nbcc = np.array(bcc)\n\nans = 0\n\nfor i, val in enumerate(acc):\n if (val > k):\n break\n else:\n rest = k - val\n print(rest)\n for j, val2 in enumerate(bcc):\n if (val2 <= rest):\n ans = max(ans, j + i)\n else:\n break\n\nprint(ans)\n ', 'import itertools\nimport numpy as np \nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nacc = list(itertools.accumulate(a))\nbcc = list(itertools.accumulate(b))\n\nacc = np.array(acc)\n#print(acc)\nbcc = np.array(bcc)\n\nans = 0\n\nfor i in acc:\n if (i > k):\n continue\n else:\n rest = k - i\n for j in bcc:\n if (j <= rest):\n ans = max(ans, j + i)\n else:\n break\n\nprint(ans)\n ', 'import itertools\nimport numpy as np \nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n# -------------------\nn, m, k = map(int, readline().split())\nprint(n)\na = list(map(int, readline().split()))\nb = list(map(int, readline().split()))\na = [0] + a\nb = [0] + b\nacc = list(itertools.accumulate(a))\nbcc = list(itertools.accumulate(b))\n\n#acc = np.array(acc)\n#print(acc)\n#bcc = np.array(bcc)\n\nans = 0\n\nfor i, val in enumerate(acc):\n if (val > k):\n break\n else:\n rest = k - val\n #print(rest)\n for j, val2 in enumerate(bcc):\n if (val2 <= rest):\n ans = max(ans, j + i)\n else:\n break\n\nprint(ans)\n \n', 'import itertools\nimport numpy as np \nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n# -------------------\nn, m, k = map(int, readline().split())\n#print(n)\na = list(map(int, readline().split()))\nb = list(map(int, readline().split()))\na = [0] + a\nb = [0] + b\nacc = list(itertools.accumulate(a))\nbcc = list(itertools.accumulate(b))\n\n#acc = np.array(acc)\n#print(acc)\n#bcc = np.array(bcc)\n\nans = 0\nj = m\nfor i, val in enumerate(acc):\n if (val > k):\n break\n else:\n rest = k - val\n #print(rest)\n #j = m\n \n while (bcc[j] > rest):\n j -= 1\n\n ans = max(ans, j + i)\n\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s353669769', 's525862088', 's751243880', 's673337853']
[66984.0, 66732.0, 65396.0, 65448.0]
[2207.0, 2207.0, 2207.0, 323.0]
[533, 456, 693, 730]
p02623
u312158169
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nif k < a[0] and k < b[0]:\n print(0)\n exit()\n\nif sum(a) + sum(b) <= k:\n print(n+m)\n exit()\n\na_temp = a[0]\nb_temp = b[0]\ntemp = 0\ncount = 0\nhour = 0\ni = 0\nj = 0\n\nwhile k > hour:\n \n count += 1\n if a_temp <= b_temp:\n hour += a_temp\n i += 1\n if i == len(a):\n a_temp = 10**10\n else:\n a_temp = a[i]\n else:\n hour += b_temp\n j += 1\n if j == len(b):\n b_temp = 10**10\n else:\n b_temp = b[i]\n\nprint(count)\n', 'n,m,k = map(int,input().split())\n\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s562826980', 's924067925']
[42224.0, 47356.0]
[256.0, 314.0]
[628, 368]
p02623
u315600877
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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())\ncostA=list(map(int,input().split()))\ncostB=list(map(int,input().split()))\ncostA=[0]+costA\ncostB=[0]+costB\n\nfor i in range(N):\n costA[i+1]+=costA[i]\n \nfor i in range(M):\n costB[i+1]+=costB[i]\n\nprint(costA)\nprint(costB)\n\ncostB.append(float("inf"))\n\ndef upper_bound(list1,K):\n low=0\n high=len(list1)-1 #index\n while high-low!=1:\n mid=(high+low)//2\n if list1[mid]>K:\n high=mid\n else:\n low=mid\n return high \n\nnumber=[]\nfor i in range(N+1): \n time=K-costA[i]\n number.append(i+upper_bound(costB,time)-1)\n print(i)\n print(upper_bound(costB,time))\n print(number)\n \nprint(max(number))\n', 'N,M,K=map(int,input("入力してください").split())\ncostA=list(map(int,input().split()))\ncostB=list(map(int,input().split()))\ncostA=[0]+costA\ncostB=[0]+costB\n\nfor i in range(N):\n costA[i+1]+=costA[i]\n \nfor i in range(M):\n costB[i+1]+=costB[i]\n\n\n\ncostB.append(float("inf"))\n\ndef upper_bound(list1,K):\n low=0\n high=len(list1)-1 #index\n while high-low!=1:\n mid=(high+low)//2\n if list1[mid]>K:\n high=mid\n else:\n low=mid\n return high \n\nnumber=[]\nfor i in range(N+1): \n time=K-costA[i]\n if upper_bound(costB,time)!=1:\n number.append(i+upper_bound(costB,time)-1)\n else:\n number.append(0)\n"""print(i)\n print(upper_bound(costB,time))\n print(number)"""\n \nprint(max(number))\n\n\n\n\n', 'N,M,K=map(int,input("入力してください").split())\ncostA=list(map(int,input().split()))\ncostB=list(map(int,input().split()))\ncostA=[0]+costA\ncostB=[0]+costB\n\nfor i in range(N):\n costA[i+1]+=costA[i]\n \nfor i in range(M):\n costB[i+1]+=costB[i]\n\nprint(costA)\nprint(costB)\n\ncostB.append(float("inf"))\n\ndef upper_bound(list1,K):\n low=0\n high=len(list1)-1 #index\n while high-low!=1:\n mid=(high+low)//2\n if list1[mid]>K:\n high=mid\n else:\n low=mid\n return high \n\nnumber=[]\nfor i in range(N+1): \n time=K-costA[i]\n if upper_bound(costB,time)!=1:\n number.append(i+upper_bound(costB,time)-1)\n else:\n number.append(0)\n print(i)\n print(upper_bound(costB,time))\n print(number)\n \nprint(max(number))', 'N,M,K=map(int,input().split())\ncostA=list(map(int,input().split()))\ncostB=list(map(int,input().split()))\ncostA=[0]+costA\ncostB=[0]+costB\n\nfor i in range(N):\n costA[i+1]+=costA[i]\n \nfor i in range(M):\n costB[i+1]+=costB[i]\n\n\n\n\n\ndef upper_bound(list1,K):\n low=0\n high=len(list1) #index\n while high-low!=1:\n mid=(high+low)//2\n if list1[mid]>K:\n high=mid\n else:\n low=mid\n return low \n\nnumber=[]\nfor i in range(N+1): \n time=K-costA[i]\n if upper_bound(costB,time)!=1:\n number.append(i+upper_bound(costB,time)-1)\n else:\n number.append(0)\n"""print(i)\n print(upper_bound(costB,time))\n print(number)"""\n \nprint(max(number))\n\n\n\n\n', 'N,M,K=map(int,input().split())\ncostA=list(map(int,input().split()))\ncostB=list(map(int,input().split()))\ncostA=[0]+costA\ncostB=[0]+costB\n\nfor i in range(N):\n costA[i+1]+=costA[i]\n \nfor i in range(M):\n costB[i+1]+=costB[i]\n\n\n\n""\n\ndef upper_bound(list1,K):\n low=0\n high=len(list1) #index\n while high-low!=1:\n mid=(high+low)//2\n if list1[mid]>K:\n high=mid\n else:\n low=mid\n return low \n\nnumber=[]\n#print(costA)\n\nfor i in range(N+1): \n time=K-costA[i]\n if time<0:\n break\n #print(i,upper_bound(costB,time))\n number.append(i+upper_bound(costB,time))\n\n"""print(i)\n print(upper_bound(costB,time))\n print(number)"""\n \nprint(max(number))\n\n\n\n\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s052467878', 's354411764', 's542146545', 's741544635', 's361321379']
[164156.0, 40112.0, 160244.0, 40200.0, 40156.0]
[2091.0, 1138.0, 2361.0, 1128.0, 659.0]
[813, 2037, 886, 1982, 2004]
p02623
u317779196
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
["'''ABC172 C'''\nimport numpy as np\nn,m,k = map(int,input().split())\na = np.array([int(i) for i in input().split()], dtype='int64')\nb = np.array([int(i) for i in input().split()], dtype='int64')\n\na_c = np.zeros(n+1,dtype='int64')\na_c[1:] = np.cumsum(a)\n\nb_c = np.zeros(m+1,dtype='int64')\nb_c[1:] = np.cumsum(b)\n\na_c = a_c[a_c <= k]\nb_c = b_c[b_c <= k]\nans = 0\nfor i,ai in enumerate(a_c):\n n = np.searchsorted(b_c, k - ai, side = 'right')\n ans = max(i + n, ans)\nprint(ans)", "import numpy as np\nn,m,k = map(int,input().split())\na = np.array([int(i) for i in input().split()], dtype='int64')\nb = np.array([int(i) for i in input().split()], dtype='int64')\n\n\na_c = np.zeros(n+1,dtype='int64')\na_c[1:] = np.cumsum(a)\n\nb_c = np.zeros(m+1,dtype='int64')\nb_c[1:] = np.cumsum(b)\n\na_c = a_c[a_c <= k]\nb_c = b_c[b_c <= k]\n\nans_l = np.searchsorted(b_c, k - a_c, side='right') - 1\nans_l += np.arange(len(a_c))\nprint(ans_l.max())"]
['Wrong Answer', 'Accepted']
['s474547178', 's690126984']
[53440.0, 53460.0]
[783.0, 237.0]
[475, 499]
p02623
u319589470
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**7)\nimport bisect\nimport heapq\nimport itertools\nimport math\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom math import gcd\nfrom operator import add, itemgetter, mul, xor\ndef cmb(n,r,mod):\n bunshi=1\n bunbo=1\n for i in range(r):\n bunbo = bunbo*(i+1)%mod\n bunshi = bunshi*(n-i)%mod\n return (bunshi*pow(bunbo,mod-2,mod))%mod\nmod = 10**9+7\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\n\n\n\nn,m,k = MI()\na = deque(LI())\nb = deque(LI())\nans = 0\nwhile k > 0 and len(a) + len(b) > 0:\n if len(a) > 0:\n book = a.popleft()\n if len(a) == 0:\n book = 10**10\n if len(b) > 0:\n book2 = b.popleft()\n if len(b) == 0:\n book2 = 10**10\n if book < book2:\n k -= book\n if k > 0:\n ans += 1\n if book > book2\n k -= book2\n if k > 0:\n ans += 1\nprint(ans)', '#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**7)\nimport bisect\nimport heapq\nimport itertools\nimport math\nfrom collections import Counter, defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import Decimal\nfrom math import gcd\nfrom operator import add, itemgetter, mul, xor\ndef cmb(n,r,mod):\n bunshi=1\n bunbo=1\n for i in range(r):\n bunbo = bunbo*(i+1)%mod\n bunshi = bunshi*(n-i)%mod\n return (bunshi*pow(bunbo,mod-2,mod))%mod\nmod = 10**9+7\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\n\n\n\nn,m,k = MI()\na = LI()\nb = LI()\na_cum = [0]\nb_cum = [0]\nans = 0\nfor i in range(1,n+1):\n a_cum.append(a[i-1]+a_cum[i-1])\nfor i in range(1,m+1):\n b_cum.append(b[i-1]+b_cum[i-1])\nfor i in range(m+1):\n K = k-b_cum[i]\n if K >= 0:\n \n j = bisect.bisect_right(a_cum, K) - 1\n ans = max(ans,i+j)\nprint(ans)\n\n']
['Runtime Error', 'Accepted']
['s068268642', 's654150904']
[8892.0, 48428.0]
[27.0, 361.0]
[1627, 1573]
p02623
u323045245
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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]*(n+1)\nB=[0]*(m+1)\nc = 0\n\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]\n#\nfor i in range(n+1):\n if A[i]>k:\n bookA=i-1\n timeA = A[i-1]\n break\nelse:\n bookA = n\n timeA = A[n]\n \nfor i in range(m+1):\n if B[i] >k:\n bookB = i-1\n timeB = B[i-1]\n break\nelse:\n bookB = m\n timeB = B[m]\n#\n"""\nprint(bookA,timeA,)\nprint(bookB,timeB)\nif bookA == 0 and bookB == 0:\n print(0)\n exit()\n"""\nif bookA < bookB:\n time = timeB\n book = bookB\n for i in range(n+1):\n if k-time < A[i]:\n break\n c = i\n else:\n c = n\n book += c \n\nelif bookA > bookB:\n book = bookA\n time = timeA\n for i in range(m+1):\n if k-time < B[i]:\n break\n c = i\n else:\n c = m\n book += c\n\nelse:\n if timeA > timeB:\n time = timeB\n book = bookB\n for i in range(n+1):\n if k-time < A[i]:\n break\n c = i\n book += c\n elif timeB > timeA:\n time = timeA\n book = bookA\n for i in range(m+1):\n if k-time < B[i]:\n break\n c = i\n book += c\n print(c)\n else:\n if A[bookA-1] > B[bookB-1]:\n book = bookB-1\n for i in range(n+1):\n if A[i] > k:\n break\n c = i\n book += c\n elif A[bookA-1] < B[bookB-1]:\n book = bookA-1\n for i in range(m+1):\n if B[i] > k:\n break\n c = i\n book += c\n else:\n book = bookA\n for i in range(m+1):\n if k-timeA < B[i]:\n book += i-1\n else:\n book += m\nif book < 0:\n print(0)\nelse:\n print(book)', 'n,m,k=map(int, input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\n\ncumA = [0]*(n+1)\nfor i in range(n):\n cumA[i+1] = cumA[i] + A[i]\n\ncumB = [0]*(m+1)\nfor i in range(m):\n cumB[i+1] = cumB[i] + B[i]\n\nans = 0\nj = m\n\nfor i in range(n+1):\n if cumA[i]>k: \n break\n while cumB[j] > k-cumA[i] and j>0: \n j -= 1\n ans = max(ans,i+j)\nprint(ans) ']
['Wrong Answer', 'Accepted']
['s067002085', 's057624721']
[47552.0, 47328.0]
[247.0, 295.0]
[1966, 570]
p02623
u324090406
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\nai = -1\nbi = -1\nanswer = 0\nt_sum = 0\nif sum(a) + sum(b) <= k:\n print(n + m)\nelif sum(a) <= k:\n t_sum = sum(a)\n ai = n-1\n while True:\n bi += 1\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi] \n bi -= 1\n answer = ai + bi + 2\n while ai >= 0:\n t_sum -= a[ai]\n ai -= 1\n while bi <= m:\n bi += 1\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi]\n bi -= 1\n if ai + bi +2 > answer:\n answer = ai + bi +2\n print(answer)\nelse:\n for i in range(n):\n t_sum += a[i]\n if t_sum > k:\n ai = i-1\n break\n while True:\n bi += 1\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi] \n bi -= 1\n answer = ai + bi + 2\n while ai >= 0:\n t_sum -= a[ai]\n ai -= 1\n while bi <= m:\n bi += 1\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi]\n bi -= 1\n if ai + bi +2 > answer:\n answer = ai + bi +2\n print(answer)', 'n, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nai = -1\nbi = -1\nanswer = 0\nt_sum = 0\nif sum(a) + sum(b) <= k:\n print(n + m)\nelif sum(a) <= k:\n t_sum = sum(a)\n ai = n-1\n while True:\n bi += 1\n if bi == m:\n break\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi] \n bi -= 1\n answer = ai + bi + 2\n while ai >= 0:\n t_sum -= a[ai]\n ai -= 1\n while bi <= m-1:\n bi += 1\n if bi == m:\n break\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi]\n bi -= 1\n if ai + bi +2 > answer:\n answer = ai + bi +2\n print(answer)\nelse:\n while True:\n ai += 1\n if t_sum + a[ai] > k:\n break\n t_sum += a[ai]\n ai -= 1\n while True:\n bi += 1\n if bi == m:\n break\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi]\n bi -= 1\n answer = ai + bi + 2\n while ai >= 0:\n t_sum -= a[ai]\n ai -= 1\n while bi <= m-1:\n bi += 1\n if bi == m:\n break\n if t_sum + b[bi] > k:\n break\n t_sum += b[bi]\n bi -= 1\n if ai + bi +2 > answer:\n answer = ai + bi +2\n print(answer)']
['Runtime Error', 'Accepted']
['s264858768', 's454605852']
[40700.0, 41736.0]
[297.0, 330.0]
[1200, 1380]
p02623
u325660636
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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_l = list(map(int, input().split()))\nb_l = list(map(int, input().split()))\n\ni_l, j_l = [0], [0]\n\nbest0 = M\nans = 0\n\nfor i in range(N):\n i_l.append(i_l[i] + a_l[i])\n\nfor i in range(M):\n j_l.append(j_l[i] + b_l[i])\n\n# for j in range(M):\n\n# if total > K:\n\n# break\n# elif total == K:\n\n# else:\n# continue\n\nfor k in range(N+1):\n if i_l[i] > K:\n break\n while i_l[k] + j_l[best0] > K:\n best0 -= 1\n ans = max(ans, k+best0)\nprint(ans)\n ', 'N, M, K = map(int, input().split())\na_l = list(map(int, input().split()))\nb_l = list(map(int, input().split()))\n\ni_l, j_l = [0], [0]\n\nbest0 = M\nans = 0\n\nfor i in range(N):\n i_l.append(i_l[i] + a_l[i])\n\nfor i in range(M):\n j_l.append(j_l[i] + b_l[i])\n\n# for j in range(M):\n\n# if total > K:\n\n# break\n# elif total == K:\n\n# else:\n# continue\n\nfor k in range(N+1):\n if i_l[k] > K:\n break\n while i_l[k] + j_l[best0] > K:\n best0 -= 1\n ans = max(ans, k+best0)\nprint(ans)\n ']
['Runtime Error', 'Accepted']
['s356010868', 's842355749']
[47480.0, 47600.0]
[281.0, 284.0]
[584, 584]
p02623
u328755070
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\ntime = 0\ncount = -1\nsaidaicho = len(A) + len(B)\nwhile time <= K:\n time += max(A[0], B[0])\n count += 1\n\n if A[0] > B[0]:\n A.pop(0)\n else:\n B.pop(0)\n\n if len(A) == 0:\n A.append(0)\n elif len(B) == 0:\n B.append(0)\n\n if count == saidaicho:\n break\nprint(count)\n', 'N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nruiA = [0]\nruiB = [0]\nfor i in range(N):\n ruiA.append(ruiA[-1] + A[i])\nfor i in range(M):\n ruiB.append(ruiB[-1] + B[i])\n\nMAX = 0\ni = 0\nfor j in range(M, -1, -1):\n if ruiA[i] + ruiB[j] <= K:\n MAX = max(MAX, i+j)\n best = j\n break\n \nfor i in range(1, N+1):\n for j in range(best, -1, -1):\n if ruiA[i] + ruiB[j] <= K:\n MAX = max(MAX, i+j)\n break\n\n\nprint(MAX)\n', 'N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nruiA = [0]\nruiB = [0]\nfor i in range(N):\n ruiA.append(ruiA[-1] + A[i])\nfor i in range(M):\n ruiB.append(ruiB[-1] + B[i])\n\nMAX = 0\nj = M\n\nfor i in range(N+1):\n if ruiA[i] > K:\n break\n while ruiA[i] + ruiB[j] > K:\n j -= 1\n MAX = max(MAX, i+j)\n\nprint(MAX)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s417361044', 's994845875', 's116065680']
[40548.0, 47492.0, 47408.0]
[2206.0, 304.0, 299.0]
[426, 526, 396]
p02623
u331105860
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\ntotal = 0\nmaxb = 0\nfor i in range(N):\n if total + A[i] <= K:\n total += A[i]\n maxb += 1\n else:\n break\n\ni = maxb - 1\nfor j in range(M):\n\n if total + B[j] <= K:\n total += B[j]\n else:\n if i == -1:\n break\n total -= A[i]\n i -= 1\n j -= 1\n\n if maxb < i + j + 2:\n maxb = i + j + 2\nprint(maxb)\n', 'N, M, K = map(int, input().split())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\n\ntotal = 0\nAsum = sum(A)\nnA = len(A)\nBsum = 0\nans = 0\nfor nB in range(len(B) + 1):\n if nB != 0:\n Bsum += B[nB-1]\n if Bsum > K:\n break\n while Asum + Bsum > K:\n nA -= 1\n Asum -= A[nA]\n ans = max(nA + nB, ans)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s843556736', 's389901503']
[42476.0, 40684.0]
[234.0, 238.0]
[486, 371]
p02623
u343490140
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\nans = 0\nj = m\nfor i in range(n + 1):\n if a[0] > 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()))\na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\nans = 0\nj = m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s808740023', 's977388778']
[47428.0, 47560.0]
[311.0, 290.0]
[361, 361]
p02623
u345621867
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nAsum = [0]\nBsum = [0]\na = 0\nb = 0\nfor i in range(N):\n a += A[i]\n Asum.append(a)\nfor i in range(M):\n b += B[i]\n Bsum.append(b)\nAsum.append(0)\nBsum.append(0)\nres, j = 0, 0\nfor i in range(N+1):\n if Asum[i] > K:\n break\n while Asum[i] + Bsum[j] > K:\n j -= 1\n res = max(res,i+j)\nprint(res)', 'N, M, K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nAsum = []\nBsum = []\nfor i in range(N):\n a = 0\n a += A[i]\n Asum.append(a)\nfor i in range(M):\n b = 0\n b += B[i]\n Bsum.append(b)\nAsum.append(0)\nBsum.append(0)\nres = 0\nfor i in range(-1,N-1):\n for j in range(-1,M-1):\n if Asum[i] + Bsum[j] <= K:\n res = max(res,(i+j+2))\n else:\n break\nprint(res)', 'N, M, K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nAsum = [0]\nBsum = [0]\na = 0\nb = 0\nfor i in range(N):\n a += A[i]\n Asum.append(a)\nfor i in range(M):\n b += B[i]\n Bsum.append(b)\nAsum.append(0)\nBsum.append(0)\nres, j = 0, M\nfor i in range(N+1):\n if Asum[i] > K:\n break\n while Asum[i] + Bsum[j] > K:\n j -= 1\n res = max(res,i+j)\nprint(res)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s015909569', 's794357984', 's259528070']
[47464.0, 41140.0, 47444.0]
[260.0, 2207.0, 288.0]
[427, 449, 423]
p02623
u346395915
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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_li = list(map(int, input().split()))\nb_li = list(map(int, input().split()))\n\na_li = [0] + a_li\nb_li = [0] + b_li\n\ntime = 0\nans = 0\na = 0\ntemp = 0\n\na_wa = [0] * (n+10)\nb_wa = [0] * (m+10)\n\ns = 0\nfor i in range(n+1):\n s += a_li[i]\n a_wa[i] = s\n\ns = 0\nfor i in range(m+1):\n s += b_li[i]\n b_wa[i] = s\n \n\nfor i in range(n+1):\n for j in range(min(ans-temp, m), m+1):\n time = a_wa[i] + b_wa[j]\n if time <= k:\n ans = max(ans, i+j)\n temp = i\n else:\n break\n \nprint(ans)', 'n,m,k = map(int, input().split())\na_li = list(map(int, input().split()))\nb_li = list(map(int, input().split()))\n\na_li = [0] + a_li\nb_li = [0] + b_li\n\ntime = 0\nans = 0\na = 0\ntemp = 0\n\na_wa = [0] * (n+10)\nb_wa = [0] * (m+10)\n\ns = 0\nfor i in range(n+1):\n s += a_li[i]\n a_wa[i] = s\n\ns = 0\nfor i in range(m+1):\n s += b_li[i]\n b_wa[i] = s\n \n\nfor i in range(n+1):\n for j in range(max(min(temp-i, m), 0), m+1):\n time = a_wa[i] + b_wa[j]\n if time <= k:\n ans = max(ans, i+j)\n temp = ans\n else:\n break\n \nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s380632982', 's728737354']
[48316.0, 47100.0]
[428.0, 530.0]
[578, 587]
p02623
u347640436
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['from itertools import accumulate\nfrom bisect import bisect_left\n\nN, M, K = map(int, input().split())\nA = list(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):\n t = K - a[i]\n if t < 0:\n break\n j = bisect_left(b, t)\n if b[j] == t:\n result = max(result, i + j + 1)\n else:\n result = max(result, i + j)\nprint(result)\n', '\nfrom 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)\n']
['Runtime Error', 'Accepted']
['s182324519', 's578015460']
[50504.0, 50584.0]
[288.0, 266.0]
[454, 411]
p02623
u349384236
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 A = list(map(int, input().split()))\n B = list(map(int, input().split()))\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\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n\tj -= 1\nans = max(ans, i + j)\nprint(ans)\n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nA=[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\ni=0\nj=m\nans=0\ntmp=0\nwhile(i<n+1 and j>=0):\n if(k>=A[i]):\n tmp=k-A[i]\n if(tmp-B[j]>=0):\n ans=max(ans,i+j)\n i+=1\n else:\n j-=1\n else:\n break\nprint(ans)\n \n \n\n \n']
['Runtime Error', 'Accepted']
['s985267820', 's167534419']
[8848.0, 47336.0]
[25.0, 359.0]
[352, 440]
p02623
u350247040
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nwhile cnt==n+m:\n if len(B)==0:\n k-=A[0]\n del A[0]\n cnt+=1\n elif len(A)==0:\n k-=B[0]\n del B[0]\n cnt+=1\n elif A[0]<=B[0] and k>A[0]:\n k-=A[0]\n del A[0]\n cnt+=1\n elif B[0]<A[0] and k>B[0]:\n k-=B[0]\n del B[0]\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\nb2=[]\nb2.append(0)\nfor i in range(1,m+1):\n b2.append(b2[i-1]+b[i-1])\na.insert(0,0)\ncnt=0\na_sum=0\nfor i in range(n+1):\n j=m\n a_sum+=a[i]\n while True:\n if k>=a_sum+b2[j]:\n cnt=max(cnt,i+j)\n m=j\n break\n j-=1\n if j <0:\n break\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s773245202', 's074162675']
[39768.0, 40696.0]
[109.0, 273.0]
[384, 363]
p02623
u352676541
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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#A = list(map(int,input().split()))\n#B = list(map(int,input().split()))\n\nN,M,K =map(int,"5 7 100".split())\nA = [10,10,20,30,3]\nB = [3,9,30,20,1,7,20]\n\n\nA_min = [0]\nfor i in range(N):\n A_min.append(A_min[i]+A[i])\nB_min = [0]\nfor i in range(M):\n B_min.append(B_min[i]+B[i])\n\n\nans = 0\nB_len = M\nfor i in range(len(A_min)):\n if A_min[i] > K:\n break\n while B_min[B_len] > K - A_min[i]:\n B_len -= 1\n ans = max(ans,i+B_len)\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\n\nA_min = [0]\nfor i in range(N):\n A_min.append(A_min[i]+A[i])\nB_min = [0]\nfor i in range(M):\n B_min.append(B_min[i]+B[i])\n\n\nans = 0\nB_len = len(B_min)\nfor i in range(len(A_min)):\n if A_min[i] > K:\n break\n while true:\n if B_min[B_len] > K - A_min[i]:\n break\n ans = max(ans,i+B_len)\n\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\n\nA_min = [0]\nfor i in range(N):\n A_min.append(A_min[i]+A[i])\nB_min = [0]\nfor i in range(M):\n B_min.append(B_min[i]+B[i])\n\n\nans = 0\nB_len = len(B_min)\nfor i in range(len(A_min)):\n if Amin[i] > K:\n break\n while true:\n if B_min[B_len] > K - A_min[i]:\n break\n ans = max(ans,i+B_len)\n\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\n\nA_min = [0]\nfor i in range(N):\n A_min.append(A_min[i]+A[i])\nB_min = [0]\nfor i in range(M):\n B_min.append(B_min[i]+B[i])\n\n\nans = 0\nB_len = M\nfor i in range(len(A_min)):\n print("i=",str(i))\n if A_min[i] > K:\n break\n while B_min[B_len] > K - A_min[i]:\n print("B_len=",str(B_len))\n print("A_min=",str(A_min[i]))\n print("B_min=",str(B_min[B_len]))\n ans = max(ans,i+B_len)\n B_len -= 1\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\n\nA_min = [0]\nfor i in range(N):\n A_min.append(A_min[i]+A[i])\nB_min = [0]\nfor i in range(M):\n B_min.append(B_min[i]+B[i])\n\n\nans = 0\nB_len = M\nfor i in range(len(A_min)):\n if A_min[i] > K:\n break\n while B_min[B_len] > K - A_min[i]:\n B_len -= 1\n ans = max(ans,i+B_len)\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s009872893', 's372798342', 's776861787', 's815132959', 's138481657']
[9216.0, 47372.0, 47368.0, 51952.0, 47500.0]
[30.0, 191.0, 184.0, 747.0, 281.0]
[618, 559, 558, 663, 537]
p02623
u353099601
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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())\nA = deque(list(map(int, input().split())))\nB = deque(list(map(int, input().split())))\n\nif sum(A) + sum(B) < K:\n print(N + M)\n exit()\n\nans = 0\n\nwhile K > 0:\n if len(A) != 0:\n # if len(B) == 0 or A[0] <= B[0]:\n if len(B) == 0 or sum(A) <= sum(B):\n if A[0] <= K:\n K -= A.popleft()\n ans += 1\n continue\n if len(B) != 0:\n # if len(A) == 0 or A[0] >= B[0]:\n if len(A) == 0 or sum(A) >= sum(B):\n if B[0] <= K:\n K -= B.popleft()\n ans += 1\n continue\n\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\nA_sum, B_sum = [0], [0]\nfor i, a in enumerate(A):\n A_sum.append(A_sum[i] + a)\nfor i, b in enumerate(B):\n B_sum.append(B_sum[i] + b)\n\nans = 0\nj = M\n\n\n\n\n\nfor i in range(N+1):\n if A_sum[i] > K:\n break\n while B_sum[j] > K - A_sum[i]:\n j -= 1\n ans = max(ans, i+j)\n\nprint(ans)\n']
['Time Limit Exceeded', 'Accepted']
['s090652836', 's491631577']
[42648.0, 48824.0]
[2206.0, 278.0]
[671, 775]
p02623
u357120030
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 functools import lru_cache\n\nri = lambda S: [int(v) for v in S.split()]\n\n\ndef rii():\n return ri(input())\n\n\nN, M, K = rii()\nA = rii()\nB = rii()\n\ni = j = 0\n\n\n@lru_cache(None)\ndef dp(i, j, k):\n ki = kj = mki = mkj = 0\n\n if i < N:\n Ki = k - A[i] if A[i] <= k else 0\n mki = 1 + dp(i + 1, j, Ki) if Ki >= 0 else 0\n if j < M:\n kj = k - B[j] if B[j] <= k else 0\n mkj = 1 + dp(i, j + 1, kj) if kj >= 0 else 0\n\n return max(mki, mkj)\n\n\nprint(dp(0, 0, K))\n#print(dp.cache_info())\n', 'ri = lambda S: [int(v) for v in S.split()]\n\n\ndef rii():\n return ri(input())\n\n\nN, M, K = rii()\nA = rii()\nB = rii()\n\ni = j = 0\n\n\ndef dp(i, j, k):\n ki = kj = mki = mkj = 0\n\n if i < N:\n Ki = k - A[i] if A[i] <= k else 0\n mki = 1 + dp(i + 1, j, Ki) if Ki >= 0 else 0\n if j < M:\n kj = k - B[j] if B[j] <= k else 0\n mkj = 1 + dp(i, j + 1, kj) if kj >= 0 else 0\n\n return max(mki, mkj)\n\n\nprint(dp(0, 0, K))\n', 'ri = lambda S: [int(v) for v in S.split()]\n\n\ndef rii():\n return ri(input())\n\n\nN, M, K = rii()\nA = rii()\nB = rii()\n\ni = j = 0\n\n\ndef dp(i, j, k):\n print(i, j, k)\n ki = kj = mki = mkj = 0\n\n if i < N:\n Ki = k - A[i] if A[i] <= k else 0\n mki = 1 + dp(i + 1, j, Ki) if Ki >= 0 else 0\n if j < M:\n kj = k - B[j] if B[j] <= k else 0\n mkj = 1 + dp(i, j + 1, kj) if kj >= 0 else 0\n\n return max(mki, mkj)\n\n\nprint(dp(0, 0, K))\n', 'from itertools import accumulate\nfrom bisect import bisect_left\n\nri = lambda S: [int(v) for v in S.split()]\n\n\ndef rii():\n return ri(input())\n\n\nN, M, K = rii()\nA = rii()\nB = rii()\n\ni = j = 0\n\npA = [0] + list(accumulate(A))\npB = [0] + list(accumulate(B))\n\nans = 0\nfor i, a in enumerate(pA):\n br = 0\n if K >= a:\n r = K - a\n br = i\n \n if r:\n j = bisect_left(pB, r)\n if j != len(pB):\n if pB[j] > r:\n j -= 1\n br += j\n \n ans = max(ans, br)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s152082375', 's207488474', 's694686679', 's302435288']
[43332.0, 42748.0, 42892.0, 50764.0]
[124.0, 125.0, 125.0, 328.0]
[515, 441, 460, 530]
p02623
u357751375
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\np = 0\nz = 0\ni = 0\nj = 0\n\nwhile p < k:\n if a[i] < b[j]:\n p += a[i]\n z += 1\n i += 1\n elif a[i] > b[j]:\n p += b[j]\n z += 1\n j += 1\n else:\n if a[i+1] < b[j+1]:\n p += a[i]\n z += 1\n i += 1\n elif:\n p += b[j]\n z += 1\n j += 1\n\nprint(z)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nx = 0\nfor i in range(n):\n x += a[i]\n a[i] = x\n\nx = 0\nfor i in range(m):\n x += b[i]\n b[i] = x\n\nx = 0\nfor i in range(n):\n x = a[i]\n if x > k:\n x = a[i-1]\n ans = i\n j = i-2\n break\n if i + 1 == n:\n ans = n\n j = i-1\n\ny = 0\nfor i in range(m):\n y = b[i]\n if x + y > k:\n while x + y > k and j >= 0:\n x = b[j]\n j -= 1\n if x + y <= k:\n ans = max(ans,i+j+2)\n\nprint(ans)', '\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\np = 0\ni = 0\nj = 0\nwhile p < k:\n if a[i] < b[j]:\n p += 1\n i += 1\n elif a[i] > b[j]:\n p += 1\n j += 1\n else:\n if a[i+1] < b[j+1]:\n p += 1\n i += 1\n else:\n p += 1\n j += 1\n\nprint(p)', 'n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = [0]*(n+1)\nd = [0]*(m+1)\nfor i in range(n):\n c[i+1] = a[i]+c[i]\nfor i in range(m):\n d[i+1] = b[i]+d[i]\nfor i in range(m+1)[::-1]:\n if d[i] <= k:\n x = i\n break\nans = x\nfor i in range(1,n+1):\n while c[i] + d[x] > k:\n if x >= 1:\n x -= 1\n else:\n break\n if c[i] + d[x] <= k:\n ans = max(ans,i+x)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s166204442', 's466171406', 's726417325', 's952820078']
[9068.0, 40464.0, 42288.0, 47344.0]
[29.0, 349.0, 212.0, 309.0]
[487, 570, 400, 478]
p02623
u358859892
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\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]\n\nI = bisect.bisect_right(a, k)\nans = bisect.bisect_right(b, k)\nli = list(range(I))\nli = li[::-1]\nfor i in li:\n tmp = bisect.bisect_right(b, k-a[i])\n if a[i] + b[tmp-1] <= k && tmp != 0:\n ans = max(ans, i+tmp+1)\n\nprint(ans)', 'import bisect\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na2 = [0] * (n + 1)\nb2 = [0] * (m + 1)\nfor i in range(0, n):\n a2[i+1] = a[i] + a2[i]\nfor i in range(0, m):\n b2[i+1] = b[i] + b2[i]\n\nans = 0\nfor i in range(n+1):\n tmp = bisect.bisect_right(b2, k-a2[i]) - 1\n if a2[i] + b2[tmp] <= k and tmp >= 0:\n ans = max(ans, i+tmp)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s492929197', 's049868800']
[9052.0, 47616.0]
[27.0, 344.0]
[440, 419]
p02623
u359358631
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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(M):\n a.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\n while a[i] + b[j] > K:\n j -= 1\n\n ans = max(ans, i + j)\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', '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\n while a[i] + b[j] > K:\n j -= 1\n\n ans = max(ans, i + j)\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s656972231', 's666798604']
[40596.0, 47452.0]
[140.0, 216.0]
[482, 482]
p02623
u363074342
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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_l = list(map(int,input().split()))\nb_l = list(map(int,input().split()))\nread_a = [0]*n\nread_b = [0]*M\ntime = 0\nans = 0\nmemo = 0\nfor j in range(n):\n if time + a_l[j] <= k:\n time += a_l[j]\n read_a[j] = 1\n memo = j\n ans = j+1\n else:\n break\n\nkotae = [ans]\n\n\ndef dfs(i,a,t,m):\n global kotae\n if i < M:\n if b_l[i] + t <= k:\n tt = t + b_l[i]\n aa = a + 1\n kotae.append(aa)\n ii = i+1\n mm = m\n #print(aa)\n dfs(ii,aa,tt,mm)\n \n else:\n if m < 0:\n continue\n tt = t - a_l[m]\n mm = m - 1\n aa = a - 1\n ii = i\n #print(aa)\n dfs(ii,aa,tt,mm)\n #print(aa)\n\n\ndfs(0,ans,time,memo)\n\n\nprint(max(kotae))\n \n\n\n\n', 'import sys\nsys.setrecursionlimit(10**6)\nn, M, k = map(int,input().split())\na_l = list(map(int,input().split()))\nb_l = list(map(int,input().split()))\nread_a = [0]*n\nread_b = [0]*M\ntime = 0\nans = 0\nmemo = -1\nfor j in range(n):\n if time + a_l[j] <= k:\n time += a_l[j]\n read_a[j] = 1\n memo = j\n ans = j+1\n else:\n break\n\nkotae = [ans]\n\n\ndef dfs(i,a,t,m):\n global kotae\n if i < M:\n if b_l[i] + t <= k:\n tt = t + b_l[i]\n aa = a + 1\n kotae.append(aa)\n ii = i+1\n mm = m\n #print(aa)\n dfs(ii,aa,tt,mm)\n \n else:\n if m >= 0:\n tt = t - a_l[m]\n mm = m - 1\n aa = a - 1\n ii = i\n dfs(ii,aa,tt,mm)\n \n\n\ndfs(0,ans,time,memo)\n\n\nprint(kotae)\n \n\n\n\n', 'n, M, k = map(int,input().split())\na_l = list(map(int,input().split()))\nb_l = list(map(int,input().split()))\nread_a = [0]*n\nread_b = [0]*M\ntime = 0\nans = 0\nmemo = 0\nfor j in range(n):\n if time + a_l[j] <= k:\n time += a_l[j]\n read_a[j] = 1\n memo = j\n ans = j+1\n else:\n break\n\nkotae = [ans]\n\n\ndef dfs(i,a,t,m):\n global kotae\n if i < M:\n if b_l[i] + t <= k:\n tt = t + b_l[i]\n aa = a + 1\n kotae.append(aa)\n ii = i+1\n mm = m\n #print(aa)\n dfs(ii,aa,tt,mm)\n \n else:\n if m < 0:\n continue\n tt = t - a_l[m]\n mm = m - 1\n aa = a - 1\n ii = i\n #print(aa)\n dfs(ii,aa,tt,mm)\n #print(aa)\n\n\ndfs(0,ans,time,memo)\n\n\nprint(max(kotae))\n \n\n\n\n', 'import sys\nsys.setrecursionlimit(10**6)\nn, M, k = map(int,input().split())\na_l = list(map(int,input().split()))\nb_l = list(map(int,input().split()))\nread_a = [0]*n\nread_b = [0]*M\ntime = 0\nans = 0\nmemo = -1\nfor j in range(n):\n if time + a_l[j] <= k:\n time += a_l[j]\n read_a[j] = 1\n memo = j\n ans = j+1\n else:\n break\n\nkotae = [ans]\n\n\ndef dfs(i,a,t,m):\n global kotae\n if i < M:\n if b_l[i] + t <= k:\n tt = t + b_l[i]\n aa = a + 1\n kotae.append(aa)\n ii = i+1\n mm = m\n #print(aa)\n dfs(ii,aa,tt,mm)\n \n else:\n if m >= 0:\n tt = t - a_l[m]\n mm = m - 1\n aa = a - 1\n ii = i\n dfs(ii,aa,tt,mm)\n \n\n\ndfs(0,ans,time,memo)\n\n\nprint(max(kotae))\n \n\n\n\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s131271905', 's342952216', 's393769352', 's485462455']
[9124.0, 408808.0, 9124.0, 405596.0]
[28.0, 630.0, 31.0, 614.0]
[874, 873, 874, 878]
p02623
u363599046
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\np, q = [0], [0]\nfor i in range(n):\n\tp.append(p[i] + a[i])\nfor i in range(m):\n\tq.append(q[i] + b[i])\n\nj, ans = m, 0\nfor i in range(N+1):\n\tif a[i] > k:\n\t\tbreak\n\n\twhile b[j] > k - a[i]:\n\t\tj -= 1\n\n\tans = 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\np, q = [0], [0]\nfor i in range(n):\n\tp.append(p[i] + a[i])\nfor i in range(m):\n\tq.append(q[i] + b[i])\n\nj, ans = m, 0\nfor i in range(n+1):\n\tif p[i] > k:\n\t\tbreak\n\n\twhile q[j] > k - p[i]:\n\t\tj -= 1\n\n\tans = max(ans, i+j)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s965204331', 's402497931']
[47496.0, 47416.0]
[191.0, 291.0]
[334, 334]
p02623
u364027015
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nimport numpy as np\nA=np.array(A).cumsum()\nB=np.array(B).cumsum()\nfor i in range(N):\n d=K-A[i]\n if d>=0:\n for j in reversed(range(M)):\n if d>=B[j]:\n if c<i+j+2:\n c=i+j+2\n M=j+1\n break\n if d<B[0]:\n c=i+1\n else:\n for j in reverse(range(M)):\n if K-B[j]>=0:\n if c<j+1:\n c=j+1\n break\n break\nprint(c)', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nc=0\nA.insert(0,0)\nB.insert(0,0)\nimport numpy as np\nA=np.array(A).cumsum()\nB=np.array(B).cumsum()\n\nfor i in range(N+1):\n d=K-A[i]\n for j in reversed(range(M+1)):\n if d-B[j]>=0:\n if c<i+j:\n c=i+j\n M=j\n break\nprint(c)']
['Runtime Error', 'Accepted']
['s908758063', 's426603356']
[45900.0, 45860.0]
[542.0, 552.0]
[477, 338]
p02623
u364386647
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['def resolve():\n N, M, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n read = deque()\n\n while sum(read) <= K:\n if len(A) == 0 and len(B) == 0:\n break\n\n if len(A) == 0:\n if sum(read) + B[0] <= K:\n read.append(B[0])\n B.pop(0)\n continue\n\n if len(B) == 0:\n if sum(read) + A[0] <= K:\n read.append(A[0])\n A.pop(0)\n continue\n\n if A[0] < B[0]:\n if sum(read) + A[0] <= K:\n read.append(A[0])\n A.pop(0)\n else:\n if sum(read) + B[0] <= K:\n read.append(B[0])\n\n B.pop(0)\n\n print(len(read))\n\n\nresolve()', 'def resolve():\n N, M, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n ans = 10 ** 10\n t = 0\n\n for i in range(M):\n t += B[i]\n j = M\n ans = 0\n for i in range(N+1):\n while j > 0 and t > K:\n j -= 1\n t -= B[j]\n \n if t > K:\n break\n \n ans = max(ans, i+j)\n \n if i == N:\n break\n t += A[i]\n \n print(ans)\n\nresolve()']
['Runtime Error', 'Accepted']
['s977441030', 's500005896']
[40096.0, 40404.0]
[111.0, 185.0]
[783, 508]
p02623
u364555831
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nsum_A = [0] * (N + 1)\nsum_B = [0] * (M + 1)\n\nfor a in range(1, N + 1):\n sum_A[a] = sum_A[a - 1] + A[a - 1]\nfor b in range(1, M + 1):\n sum_B[b] = sum_B[b - 1] + B[b - 1]\n\ncount = 0\n\nprint(sum_A)\nprint(sum_B)\nlast_index = M\n\nfor a in range(len(sum_A)):\n print("----------------------")\n print("a", a)\n if sum_A[a] >= K:\n count = max(count, a)\n break\n now = sum_A[a]\n rest = K - now\n print("last_index", last_index)\n \n\n while True:\n if last_index < 0:\n able = 0\n break\n if sum_B[last_index] > rest:\n last_index -= 1\n else:\n able = last_index\n break\n\n print("now", now, "rest", rest, "able", able)\n print("今回の最大countは", "a + able = ", a + able)\n count = max(count, a + able)\n print("これまでの最大count", count)\n\nprint(count)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nsum_A = [0] * (N + 1)\nsum_B = [0] * (M + 1)\n\nfor a in range(1, N + 1):\n sum_A[a] = sum_A[a - 1] + A[a - 1]\nfor b in range(1, M + 1):\n sum_B[b] = sum_B[b - 1] + B[b - 1]\n\ncount = 0\n\n# print(sum_A)\n\nlast_index = M\n\nfor a in range(len(sum_A)):\n # print("----------------------")\n # print("a", a)\n if sum_A[a] > K:\n count = max(count, a - 1)\n break\n elif sum_A[a] == K:\n count = max(count, a)\n now = sum_A[a]\n rest = K - now\n \n \n\n while True:\n if last_index < 0:\n able = 0\n break\n if sum_B[last_index] > rest:\n last_index -= 1\n else:\n able = last_index\n break\n\n \n \n count = max(count, a + able)\n \n\nprint(count)\n']
['Wrong Answer', 'Accepted']
['s286296166', 's375606528']
[74760.0, 47488.0]
[1106.0, 329.0]
[1047, 1120]
p02623
u365077014
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 INF 2000000000\n#define MOD 1000000007\n#define EPS (1e-10)\n\nusing namespace std;\n\nint main(int argc, char *argv[]) {\n\n\tlong N,M; cin >> N >> M;\n\tlong K; cin >> K;\n\t\n\tvector<long> A(N+1,0);\n\tfor (int i = 1; i <= N; i++) {\n\t\tint a; cin >> a;\n\t\tA[i] = A[i-1] + a;\n\t}\n\n\tvector<long> B(M+1,0);\n\tfor (int i = 1; i <= M; i++) {\n\t\tint b; cin >> b;\n\t\tB[i] = B[i-1] + b;\n\t}\n\n\tlong ans = 0;\n\tlong best = M;\n\tfor (int i = 1; i <= N; i++) {\n\t\tif (A[i] > K) {\n\t\t\tbreak;\t\n\t\t}\n\t\t\n\t\twhile (1 < best and B[best] > K - A[i]) {\n\t\t\tbest--;\t\t\n\t\t}\n\t\tans = max(ans, i+best);\n\n\t}\n\tcout << ans << endl;\n\n\n\n\treturn 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\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)']
['Runtime Error', 'Accepted']
['s976899559', 's984852369']
[8876.0, 47364.0]
[24.0, 279.0]
[624, 341]
p02623
u366996583
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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())\nimport numpy as np\na=np.array(list(map(int,input().split())))\nb=np.array(list(map(int,input().split())))\na_s=a.cumsum()\nb_s=b.cumsum()\nan=0\nans=0\nwhile an<N and a_s[an]<=K:\n bn=0\n while bn<M and a_s[an]+b_s[bn]<=K:\n bn+=1\n if an+bn+1>ans:\n ans=an+bn+1\n an+=1\nprint(ans)', 'N,M,K=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\na_s=[0]\nb_s=[0]\nfor i in range(N):\n if a_s[i]+a[i]>K:\n break\n a_s.append(a[i]+a_s[i])\nfor i in range(M):\n if b_s[i]+b[i]>K:\n break\n b_s.append(b[i]+b_s[i])\nbn=len(b_s)-1\nans=0\nfor i in range(len(a_s)):\n while a_s[i]+b_s[bn]>K:\n bn-=1\n ans=max(ans,i+bn)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s782453138', 's518968680']
[8940.0, 40748.0]
[24.0, 328.0]
[312, 378]
p02623
u370576244
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nr0=0\nrr = 0\nt0=0\ni = 0\nj = 0\nflag = 0\n\nwhile t0<=K:\n t0 = t0 + A[i]\n if t0<=K:\n r0 = r0 + 1\n print(t0,r0)\n if i==N-1:\n break\n i = i + 1\n\nif t0>K:\n t0 = t0 - A[i]\n\nwhile t0<=K:\n t0 = t0 + B[j]\n if t0<=K:\n r0 = r0 + 1\n print(t0,r0)\n if j==M-1:\n flag = 1\n break\n j = j + 1\n\nif t0>K:\n t0 = t0 - B[j]\n\nrr = r0\nKk = K\ntk = t0\nrk = r0\n\nfor k in range(i):\n if flag == 1:\n break\n Kk = Kk + A[i-k] - tk\n print(Kk)\n tk = 0\n ik = 0\n rk = rk - 1\n while tk<=Kk:\n tk = tk + B[j]\n if tk<=Kk:\n rk = rk + 1\n print(tk,rk)\n if j == M-1:\n flag = 1\n break\n j = j+1\n rr = max(rk,rr)\n\n\nprint(rr)', '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 = j-1\n Ans = max(Ans,i+j)\n\nprint(Ans)']
['Wrong Answer', 'Accepted']
['s503112356', 's581329476']
[41076.0, 47436.0]
[588.0, 288.0]
[897, 336]
p02623
u370721525
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\ndef doku(li, K, time):\n cnt = 0\n tmp = 0\n for i in range(len(li)):\n if time+li[i] <= K:\n tmp += li[i]\n cnt += 1\n else:\n return cnt\n return cnt\n\nans = 0\ntime = 0\nwhile time+min(A[0], B[0]) <= K:\n plus = min(A[0], B[0])\n time += plus\n ans += 1\n if A[0] <= B[0]:\n A.pop(0)\n if not A:\n ans += doku(B, K, time)\n print('A')\n break;\n else:\n B.pop(0)\n if not B:\n ans += doku(A, K, time)\n print('B')\n break;\n print(A, B, time, 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]\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 b[j] > K-a[i]:\n j -= 1\n ans = max(ans, i+j)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s602102478', 's562343345']
[158524.0, 47456.0]
[2369.0, 300.0]
[620, 344]
p02623
u374935093
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\nans = 0\nA_array = np.array(A)\nB_array = np.array(B)\nA_cum = np.cumsum(A_array)\nB_cum = np.cumsum(B_array)\nfor i in range(len(A_cum)):\n k = A_cum[i]\n if k >K:\n break\n a = 0\n b = len(B_cum)-1\n print(B_check)\n while b - a != 0:\n c = int(round((a+b)/2))\n if B_check[c] < 0:\n b = c\n else:\n a = c\n if b-a == 1:\n if B_check[b] < 0:\n b = a\n else:\n a = b\n check = i+b+2\n if check>ans:\n ans = check\nprint(ans)', 'import bisect\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\nA_cum = [0]\nB_cum = [0]\nA_cum[0] = A[0]\nfor j in range(len(A)-1):\n A_cum.append(A_cum[j]+ A[j+1])\nB_cum[0] = B[0]\nfor l in range(len(B)-1):\n B_cum.append(B_cum[l] + B[l+1])\nfor i in range(len(A_cum)):\n k = A_cum[i]\n if k >K:\n break\n b = bisect.bisect(B_cum,K-k)\n check = i+b+1\n if check>ans:\n ans = check\ncheck = bisect.bisect(B_cum,K)\nif check>ans:\n ans = check \nprint(ans)']
['Runtime Error', 'Accepted']
['s414669920', 's653909832']
[58420.0, 49068.0]
[223.0, 301.0]
[661, 540]
p02623
u377834804
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nmmax = 0\npre = False\nnum = 0\nans = 0\nans2 = 0\nfor i in range(N+1):\n if i == 0:\n ans = 0\n else:\n ans += A[i-1]\n if ans > K:\n break\n for j in range(M+1):\n if j == 0:\n ans2 = ans\n else:\n ans2 += B[j-1]\n if ans2 > K:\n break\n else:\n mmax = max(mmax, i+j)\n print(i, j, ans2, mmax)\n\nprint(mmax)', '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.appned(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(len(A)):\n if a[i] > K:\n break\n while B[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n \npa, pb = 0, 0\n \nans = 0\nfa, fb = False, False\nwhile 1:\n if pa >= N and pb < M:\n if K - B[pb] >= 0:\n ans += 1\n pb += 1\n else:\n break\n elif pb >= M and pa < N:\n if K - A[pa] >= 0:\n ans += 1\n pa += 1\n else:\n break\n elif pa >= N and pb >= M:\n break\n elif A[pa] < B[pb]:\n if K - A[pa] >= 0:\n ans += 1\n pa += 1\n else:\n break\n else:\n if K - B[pb] >= 0:\n ans += 1\n pb += 1\n else:\n break\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\npa, pb = 0, 0\n\nans = 0\nwhile 1:\n if A[pa] < B[pb]:\n if K - A[pa] >= 0:\n ans += 1\n pa += 1\n else:\n break\n else:\n if K - B[pb] >= 0:\n ans += 1\n pb += 1\n else:\n break', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n \na = [0]\nb = [0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans, 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', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s040076614', 's043819332', 's578979115', 's596897794', 's001635819']
[60448.0, 40516.0, 39900.0, 40440.0, 47320.0]
[2567.0, 114.0, 252.0, 190.0, 284.0]
[444, 339, 591, 316, 337]
p02623
u380408685
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nimport sys\n\nl = stdin.readline().rstrip().split(\' \')\na = stdin.readline().rstrip().split(\' \')\nb = stdin.readline().rstrip().split(\' \')\nk = int(l[2])\nn = int(l[0])\nm = int(l[1])\nia = 0\nib = 0\nb_sum = 0\ncount = 0\na_sum = 0\nres = []\n\nfor ib in range(m):\n b_sum += int(b[ib])\n if b_sum <= k:\n count += 1\n else:\n break\nres.append(count)\ncount = 0\nfor ia in range(n):\n a_sum = a_sum + int(a[ia])\n if k < a_sum:\n #print("ok")\n res.append(count)\n continue\n else:\n count = ia + 1\n b_sum = a_sum\n for ib in range(m):\n b_sum += int(b[ib])\n if b_sum <= k:\n count += 1\n else:\n break\n res.append(count)\nprint(res)', "from sys import stdin\nimport sys\n\nl = stdin.readline().rstrip().split(' ')\na = stdin.readline().rstrip().split(' ')\nb = stdin.readline().rstrip().split(' ')\nk = int(l[2])\nn = int(l[0])\nm = int(l[1])\nia = 0\nib = 0\nsum = 0\ncount = 0\na_sum = 0\nres = []\nb_list = []\nfor bt in b:\n sum += int(bt)\n if sum <= k:\n count += 1\n b_list.append(sum)\n else:\n break\n#print(b_list)\nres.append(count)\ncount = 0\nia = 1\nfor at in a:\n a_sum += int(at)\n if k < a_sum:\n print(max(res))\n sys.exit()\n count = ia\n sum = a_sum\n for bsum in b_list:\n sum = a_sum + bsum\n if k < sum:\n print(max(res))\n sys.exit()\n else:\n count += 1\n ia += 1\n res.append(count)\nprint(max(res))", "from sys import stdin\nimport sys\n\nl = stdin.readline().rstrip().split(' ')\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nk = int(l[2])\nn = int(l[0])\nm = int(l[1])\n\nsum = 0\na = [0]\nfor i in range(n):\n sum += A[i]\n a.append(sum)\nsum = 0\n\nb = [0]\nfor i in range(m):\n sum += B[i]\n b.append(sum)\n#print(b)\n\nans = 0\nj = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s596274643', 's736984543', 's070940948']
[42060.0, 46840.0, 47268.0]
[2206.0, 2207.0, 297.0]
[733, 765, 482]
p02623
u382639013
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nans = 0\n\nif ab_min > K:\n ans = 0\nelse:\n while True:\n K = K - min(A[0],B[0])\n if K < 0:\n break\n ans += 1\n if min(A[0],B[0])==A[0]:\n A.pop(0)\n if A == []:\n A.append(10**9+1)\n else:\n B.pop(0)\n if B == []:\n B.append(10**9+1)\nprint(ans)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans = 0 \nfor i in range(n + 1):\n if a[i] > k:\n break\n while a[i] + b[m] > k:\n m -= 1\n ans = max(ans, i + m)\nprint(ans)']
['Runtime Error', 'Accepted']
['s564347165', 's564723510']
[40548.0, 47508.0]
[113.0, 298.0]
[472, 357]
p02623
u385677760
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\na.append(a[i] + A[i])\nfor i in range(M):\nb.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\nif a[i] > K:\nbreak\nwhile b[j] > K - a[i]:\nj -= 1\nans = max(ans, i + j)\nprint(ans)', 'N,M,K = (int(x) for x in input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ni = 0\nj = 0\ntime = 0\ncount = 0\nbuff = -1\nwhile time < K and count-buff == 1 and i < N or j < M:\n buff = count\n if i >= N or j >= M:\n if i >= N:\n if K-time>B[j]:\n time += B[j]\n j += 1\n count += 1\n elif j >= M:\n if K-time>A[i]:\n time += A[i]\n i += 1\n count += 1\n else:\n if A[i] < B[j]:\n if K-time>A[i]:\n time += A[i]\n i += 1\n count += 1\n elif A[i] >= B[j]:\n if K-time>B[j]:\n time += B[j]\n j += 1\n count += 1\n\nprint(count)', 'N,M,K = (int(x) for x in input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ni = 0\nj = 0\ntime = 0\ncount = 0\nbuff = 0\nwhile time < K and count-buff ==1 and i < N or j < M:\n buff = count\n if i >= N or j >= M:\n if i >= N:\n time += B[j]\n j += 1\n count += 1\n elif j >= M:\n time += A[i]\n i += 1\n count += 1\n else:\n if A[i] < B[j]:\n time += A[i]\n i += 1\n count += 1\n elif A[i] >= B[j]:\n time += B[j]\n j += 1\n count += 1\n\nprint(count)', 'N,M,K = (int(x) for x in input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ni = 0\nj = 0\ntime = 0\ncount = 0\nbuff = -1\nwhile time < K and count-buff == 1 and i < N or j < M:\n buff = count\n if i >= N or j >= M:\n if i >= N:\n time += B[j]\n j += 1\n count += 1\n elif j >= M:\n time += A[i]\n i += 1\n count += 1\n else:\n if A[i] < B[j]:\n time += A[i]\n i += 1\n count += 1\n elif A[i] >= B[j]:\n time += B[j]\n j += 1\n count += 1\n\nprint(count)', 'N,M,K = (int(x) for x in input().split())\nA = list(map(int, input.split()))\nB = list(map(int, input.split()))\ni,j = 0\ntime = 0\nwhile time < K and i < N-1 or j < M-1:\n if A[i] < B[j]:\n time += A[i]\n i += 1\n elif A[i] > B[j]:\n time += B[j]\n j += 1\nallbooks = i + j\nprint(allbooks)', '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', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s084458505', 's139056827', 's232927579', 's576569074', 's604299024', 's879053928']
[9004.0, 40056.0, 42212.0, 41912.0, 9164.0, 47600.0]
[26.0, 2206.0, 286.0, 286.0, 24.0, 279.0]
[324, 794, 632, 634, 312, 360]
p02623
u388497015
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na_acc = [0]\nb_acc = [0]\nnow = 0\nfor i in range(n):\n now += a[i]\n a_acc.append(now)\n\nnow = 0\nfor i in range(m):\n now += b[i]\n b_acc.append(now)\n\nans = 0\nfor i in range(n+1):\n t = k - a_acc[i]\n if t < 0:\n break\n ind = bisect.bisect_left(b_acc, t)\n ans = max(ans, i+ind)\n\nprint(ans)\n', 'import bisect\nn, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\na_acc = [0]\nb_acc = [0]\nnow = 0\nfor i in range(n):\n now += a[i]\n a_acc.append(now)\n\nnow = 0\nfor i in range(m):\n now += b[i]\n b_acc.append(now)\n\nans = 0\nfor i in range(n+1):\n t = k - a_acc[i]\n if t < 0:\n break\n ind = bisect.bisect_left(b_acc, t)\n if ind == m+1:\n ans = max(ans, i+m)\n ind -= 1\n if b_acc[ind] == t:\n ans = max(ans, i+ind)\n else:\n ans = max(ans, i+ind-1)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s563245710', 's325479859']
[47368.0, 47396.0]
[310.0, 398.0]
[419, 533]
p02623
u388971072
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nAin = 0\nBin = 0\nlenA = len(A)\nlenB = len(B)\nif(min(min(A),min(B))>K):\n print(0)\n exit()\nwhile time<=K:\n if((lenA!=Ain) and (lenB!=Bin)):\n if(A[Ain]<B[Bin]):\n time+= A[Ain]\n Ain+=1\n count +=1\n elif(A[Ain]>B[Bin]):\n time += B[Bin]\n Bin+=1\n count+=1\n if((lenA==Ain) and (lenB==Bin)):\n break\n elif(lenA==Ain):\n time += B[Bin]\n Bin += 1\n count += 1\n elif(lenB==Bin):\n time += A[Ain]\n Ain += 1\n count += 1\nif(time == K):\n print(count)\nelse:\n print(count-1)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\ncount = 0\nAin = 0\nBin = 0\ncheck = False\nif(min(min(A),min(B))>K):\n print(0)\nwhile K>=0:\n if(Ain != N and Bin !=M): \n if(A[Ain] < B[Bin]):\n K-=A[0]\n Ain += 1\n else:\n K-=B[0]\n Bin += 1\n \n elif((Ain == N) and (Bin == M)):\n check = True\n break\n if(Ain==N):\n K -= B[Bin]\n Bin += 1\n elif(Bin==M):\n K -= A[Ain]\n Ain += 1\nif(K==0 or check):\n print(Ain+Bin)\nelse:\n print(Ain+Bin-1)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nA_sum = [0]\nB_sum = [0]\nA_sum.extend(A)\nB_sum.extend(B)\nfor i in range(1,N+1):\n A_sum[i]+=A_sum[i-1]\nfor i in range(1,M+1):\n B_sum[i]+=B_sum[i-1]\nans,j=0,M\nfor i in range(N+1):\n if A_sum[i]>K:\n break\n while B_sum[j]+A_sum[i]>K:\n j-=1\n ans = max(ans,i+j)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s767777577', 's960878285', 's374799861']
[40448.0, 40584.0, 49128.0]
[2206.0, 243.0, 277.0]
[725, 603, 396]
p02623
u391589398
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 = tuple(map(int, input().split()))\nB = tuple(map(int, input().split()))\nimport numpy as np\nfrom itertools import accumulate\nAS = np.array([0] + list(accumulate(A)))\nBS = np.array([0] + list(accumulate(B)))\n\nans = 0\nfor i in range(n+1):\n if AS[i] > k:\n break\n for j in range(ans-i-1, m+1):\n if AS[i] + BS[j] > k:\n break\n ans = max(ans, i+j)\n \nprint(ans)\n', 'n, m, k = map(int, input().split())\nA = tuple(map(int, input().split()))\nB = tuple(map(int, input().split()))\n\nfrom itertools import accumulate\nAS = [0] + list(accumulate(A))\nBS = [0] + list(accumulate(B))\n\nfrom bisect import bisect\nans = 0\nfor i in range(n+1):\n if AS[i] > k:\n break\n \n # ans = max(ans, kb+i)\n ans = max(ans, bisect(BS, k - AS[i])-1+i)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s310565898', 's355311193']
[56820.0, 50684.0]
[986.0, 283.0]
[436, 414]
p02623
u392441504
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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())) for _ in range(N)]\n\nB = [list(map(int, input().split())) for _ in range(M)]\n\nsum=0\ncount = 0\nfor i in range(N+M):\n if A[0] >= B[0]:\n temp = B.pop(0)\n if sum+temp > K:\n break\n print(count)\n else:\n sum +=temp\n count += 1\n\n else:\n temp = A.pop(0)\n if sum + temp > K:\n break\n print(count)\n else:\n sum += temp\n count += 1\n\n\n\n\n\n\n', 'N,M,K = map(int, input().split())\n\n \nA = list(map(int, input().split()))\n\nB = list(map(int, input().split()))\nsum=0\ncount = 0\nfor i in range(N+M):\n if A[0] >= B[0]:\n temp = B.pop(0)\n if sum+int(temp) > K:\n break\n print(count)\n else:\n sum +=temp\n count += 1\n\n else:\n temp = A.pop(0)\n if sum + int(temp) > K:\n break\n print(count)\n else:\n sum += temp\n count += 1\n\n\n\n\n\n\n', 'N,M,K = map(int, input().split())\n \nA = [list(map(int, input().split())) for _ in range(N)]\n\nB = [list(map(int, input().split())) for _ in range(M)]\n\nsum=0\ncount = 0\nfor i in range(N+M):\n if A[0] >= B[0]:\n temp = B.pop(0)\n if sum+temp > K:\n break\n print(count)\n else:\n sum +=temp\n count += 1\n\n else:\n temp = A.pop(0)\n if sum + temp > K:\n break\n print(count)\n else:\n sum += temp\n count += 1\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()))\n\n\na = [0]\nb = [0]\n\nfor i in range(n):\n a.append(a[i]+ A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n# print(a)\n# print(b)\n# print(a[3])\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)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s146569395', 's290617951', 's386493924', 's591750438']
[40700.0, 40556.0, 40536.0, 47360.0]
[105.0, 2206.0, 107.0, 298.0]
[551, 521, 551, 389]
p02623
u394731058
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n ,m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\nwhile k > 0:\n i, j = 0\n if a[i] <= b[j]:\n k -= a[i]\n if k >= 0\n i += 1\n ans += 1\n else:\n k -= b[j]\n if k >= 0\n j += 1\n ans += 1\nprint(ans)', 'n ,m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\nwhile k > 0:\n i, j = 0\n if a[i] <= b[j]:\n k -= a[i]\n if k >= 0\n i += 1\n ans += 1\n if i >= n:\n for o in range(j, m):\n if k >= b[o]:\n k -= b[o]\n ans += 1\n else:\n k -= b[o]\n break\n else:\n k -= b[j]\n if k >= 0\n j += 1\n ans += 1\n if j >= m:\n for p in range(i, n):\n if k >= a[p]:\n k -= a[p]\n ans += 1\n else:\n k -= a[p]\n break\nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_cs, b_cs = [0], [0]\nfor i in range(n):\n a_cs.append(a_cs[i] + a[i])\nfor i in range(m):\n b_cs.append(b_cs[i] + b[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if a_cs[i] > k:\n break\n while b_cs[j] > k - a_cs[i]:\n j -= 1\n ans = min(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_cs, b_cs = [0], [0]\nfor i in range(n):\n a_cs.append(a_cs[i] + a[i])\nfor i in range(m):\n b_cs.append(b_cs[i] + b[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if a_cs[i] > k:\n break\n while b_cs[j] > k - a_cs[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s245628729', 's480091243', 's979805771', 's834444322']
[9032.0, 8952.0, 47492.0, 47552.0]
[24.0, 25.0, 282.0, 288.0]
[289, 629, 369, 369]
p02623
u395894569
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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())\na = [int(_) for _ in input().split()]\nb = [int(_) for _ in input().split()]\n\nx = deque(a)\ny = deque(b)\n\nans=0\nfor i in range(n + m):\n print(x, y)\n try:\n temp = x.popleft() if x[0] < y[0] else y.popleft()\n except:\n if len(x) == 0:\n temp = y.popleft()\n elif len(y) == 0:\n temp=x.popleft()\n print(temp)\n\n k -= int(temp)\n if k >= 0:\n ans += 1\n else:\n break\nprint(ans)', 'n,m,k = map(int, input().split())\na = [int(_) for _ in input().split()]\nb = [int(_) for _ in input().split()]\n\nt = sum(b)\nj = m\nans = 0\nfor i in range(n+1):\n while j > 0 and t > k:\n j -= 1\n t -= b[j]\n if t > k: break\n ans = max(ans, i + j)\n if i==n:break\n t+=a[i]\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s714026732', 's686189652']
[162748.0, 40660.0]
[2384.0, 249.0]
[514, 304]
p02623
u396210538
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nimport sys\nimport math\nimport random\nfrom decimal import Decimal\n\n\nN, M, K = [int(x) for x in stdin.readline().rstrip().split()]\nA = list(map(int, input().split()))\nA1 = [0]\nfor i, v in enumerate(A):\n x = A1[i]+v\n A1.append(x)\nB = list(map(int, input().split()))\nB1 = [0]\nfor i, v in enumerate(B):\n x = B1[i]+v\n B1.append(x)\nc1 = 0\nc2 = 0\nans = 0\ntemp = 0\nprint(A1, B1)\nfor i in range(len(A1)):\n if A1[i] > K:\n break\n for k in range(len(B1)):\n if B1[k] > K:\n break\n if A1[i]+B1[k] <= K:\n if i+k > ans:\n ans = i+k\nprint(ans)', 'from sys import stdin\nimport sys\nimport math\nimport random\nfrom decimal import Decimal\n\n\nN, M, K = [int(x) for x in stdin.readline().rstrip().split()]\nA = list(map(int, input().split()))\nA1 = [0]\nfor i, v in enumerate(A):\n x = A1[i]+v\n A1.append(x)\nB = list(map(int, input().split()))\nB1 = [0]\nfor i, v in enumerate(B):\n x = B1[i]+v\n B1.append(x)\nc1 = 0\nc2 = 0\nans = 0\ntemp = M\n\nfor i in range(N+1):\n if A1[i] > K:\n break\n while B1[temp] > K-A1[i]:\n temp -= 1\n ans = max(ans, i+temp)\n # for k in range(temp, 0, -1):\n # if A1[i]+B1[k] <= K:\n # ans = max(ans, i+k)\n # temp = k\n # break\n# print(c1, c2)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s118280687', 's103320962']
[57068.0, 51832.0]
[2214.0, 304.0]
[621, 690]
p02623
u396211450
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\na=[0]\nb=[0]\nfor i in range(N):\n\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)\n', 'N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\na=[0]\nb=[0]\nfor i in range(N):\n\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s739137565', 's366792583']
[40700.0, 47364.0]
[112.0, 281.0]
[319, 319]
p02623
u398383435
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 = input().split()\n\nN = int(N)\nM = int(M)\nK = int(K)\n\nA = list(input().split())\nA = [int(c) for c in A]\n\nSum_A = [0]\nele_A = 0\na = 0\n\nwhile Sum_A[-1] + A[a] <= K:\n ele_A += A[a]\n a += 1\n Sum_A.append(ele_A)\n if a == len(A):\n break\n\nB = list(input().split())\nB = [int(c) for c in B]\n\nSum_B = [0]\nele_B = 0\nb = 0\n\nwhile Sum_B[-1] + B[b] <= K:\n ele_B += B[b]\n b += 1\n Sum_B.append(ele_B)\n if b == len(B):\n break\n\nh = len(Sum_A) - 1\ni = 0\nj = 0\n\nwhile h > 0:\n while Sum_A[h] + Sum_B[i] <= K:\n j = max(j,h + i)\n i += 1\n if i == len(Sum_B) - 1:\n break\n if i == len(Sum_B) - 1:\n j = max(j,h + i)\n break\n h -= 1\n\nprint(j)', 'N,M,K = input().split()\n\nN = int(N)\nM = int(M)\nK = int(K)\n\nA = list(input().split())\nA = [int(c) for c in A]\n\nSum_A = [0]\nele_A = 0\na = 0\n\nwhile Sum_A[-1] + A[a] <= K:\n ele_A += A[a]\n a += 1\n Sum_A.append(ele_A)\n if a == len(A):\n break\n\nB = list(input().split())\nB = [int(c) for c in B]\n\nSum_B = [0]\nele_B = 0\nb = 0\n\nwhile Sum_B[-1] + B[b] <= K:\n ele_B += B[b]\n b += 1\n Sum_B.append(ele_B)\n if b == len(B):\n break\n\nh = len(Sum_A) - 1\ni = 0\nj = 0\n\nwhile h >= 0:\n while Sum_A[h] + Sum_B[i] <= K:\n j = max(j,h + i)\n if i == len(Sum_B) - 1:\n break\n i += 1\n if h == 0:\n break\n h -= 1\n\nprint(j)']
['Wrong Answer', 'Accepted']
['s325214086', 's151032396']
[47764.0, 48528.0]
[422.0, 454.0]
[711, 674]
p02623
u399155892
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
["#!/usr/bin/env python\nfrom collections import deque\n\ndef main():\n n, m, k = map(int, input().split())\n a_lst = list(map(int, input().split()))\n b_lst = list(map(int, input().split()))\n if n < m:\n a_lst, b_lst = b_lst, a_lst\n n, m = m, n\n\n a_time = [0]\n b_time = []\n\n t = 0\n for a in a_lst:\n t += a\n if t > k:\n break\n a_time.append(t)\n t = 0\n for b in b_lst:\n t += b\n if t > k:\n break\n b_time.append(t)\n\n a_que = deque(a_time)\n b_que = deque(b_time)\n cnt = len(a_que)\n c_max = cnt - 1\n while c_max <= cnt and a_que and b_que:\n cnt -= 1\n a = a_que.pop()\n b = b_que.popleft()\n while a + b <= k:\n cnt += 1\n c_max = cnt\n if b_que:\n b = b_que.popleft()\n else:\n break\n\n print(c_max)\n\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python\nfrom collections import deque\n\ndef main():\n n, m, k = map(int, input().split())\n a_lst = list(map(int, input().split()))\n b_lst = list(map(int, input().split()))\n if n < m:\n a_lst, b_lst = b_lst, a_lst\n n, m = m, n\n\n a_time = [0]\n b_time = [0]\n\n t = 0\n for a in a_lst:\n t += a\n if t > k:\n break\n a_time.append(t)\n t = 0\n for b in b_lst:\n t += b\n if t > k:\n break\n b_time.append(t)\n\n ret = 0\n j = len(b_time) - 1\n for i, a in enumerate(a_time):\n while a + b_time[j] > k:\n j -= 1\n ret = max(ret, i+j)\n\n print(ret)\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s244436795', 's366645174']
[44176.0, 42184.0]
[178.0, 220.0]
[944, 718]
p02623
u401810884
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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(2147483647)\n\nN, M, K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nAsum = []\nBsum = []\ncount = 0\nfor p in A:\n count += p\n Asum.append(count)\ncount = 0\nfor p in B:\n count += p\n Bsum.append(count)\nbest = 0\nBlast = M-1\nfor t in range(N):\n if Asum(t) > K:\n break\n if best < t+1:\n best=t+1\n for s in reversed(range(0,Blast+1)):\n if Asum[t]+Bsum[s]<=K:\n if best < t+1+s+1:\n best=t+1+s+1\n Blast = s\n break\nprint(best)\n\n', 'import sys\nsys.setrecursionlimit(2147483647)\n\nN, M, K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nAsum = [0]\nBsum = [0]\ncount = 0\nfor p in A:\n count += p\n Asum.append(count)\ncount = 0\nfor p in B:\n count += p\n Bsum.append(count)\nbest = 0\nBlast = M-1\nfor t in range(N+1):\n if Asum[t] > K:\n break\n if best < t+1:\n best=t+1\n for s in reversed(range(0,Blast+1)):\n if Asum[t]+Bsum[s]<=K:\n if best < t+1+s+1:\n best=t+1+s+1\n Blast = s\n break\nprint(best)\n\n', 'import sys\nsys.setrecursionlimit(2147483647)\n\nN, M, K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nAsum = [0]\nBsum = [0]\ncount = 0\nfor p in A:\n count += p\n Asum.append(count)\ncount = 0\nfor p in B:\n count += p\n Bsum.append(count)\nbest = 0\nBlast = M-1\nfor t in range(N+1):\n if Asum[t] > K:\n break\n if best < t:\n best=t\n for s in reversed(range(0,Blast+1)):\n if Asum[t]+Bsum[s]<=K:\n if best < t+s+1:\n best=t+s+1\n Blast = s\n break\nprint(best)\n\n', 'import sys\nsys.setrecursionlimit(2147483647)\n\nN, M, K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nAsum = [0]\nBsum = [0]\ncount = 0\nfor p in A:\n count += p\n Asum.append(count)\ncount = 0\nfor p in B:\n count += p\n Bsum.append(count)\nbest = 0\nBlast = M\nfor t in range(N+1):\n if Asum[t] > K:\n break\n if best < t:\n best=t\n for s in reversed(range(0,Blast+1)):\n if Asum[t]+Bsum[s]<=K:\n if best < t+s:\n best=t+s\n Blast = s\n break\nprint(best)\n\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s120867920', 's144162738', 's363190917', 's033854230']
[47144.0, 47384.0, 47504.0, 47180.0]
[196.0, 352.0, 341.0, 334.0]
[580, 584, 576, 570]
p02623
u405276711
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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,nb,k = map(int, input().split())\nta = map(int, input().split())\ntb = map(int, input().split())\n\ndef get_bcnt( usek,tb=tb ):\n t = 0\n cnt = 0\n try:\n while True:\n if t + tb[cnt] > usek:\n return cnt\n else:\n t += tb[cnt]\n cnt += 1\n except:\n return len(tb)\n\nsumta = 0\nreadbook = [get_bcnt(k)] \nfor i in range(na):\n sumta += ta[i]\n if sumta > k:\n break\n if ta[i] <= k:\n readbook.append( i+1 + get_bcnt( k - sumta ) )\n\nprint( max(readbook) )\n ', 'na,nb,k = map(int, input().split())\nta = list(map(int, input().split()))\ntb = list(map(int, input().split()))\n\n\ndef get_bcnt( usek,tb=tb ):\n tb_sum = [ sum(tb[:i]) + tt for i, tt in enumerate(tb)]\n tb_sum_tf = [ i <= usek for i in tb_sum]\n \n if False in tb_sum_tf:\n return tb_sum_tf.index(False)\n else:\n return len(tb)\n \n \nreadbook = [ i+1 + get_bcnt( k - sum( ta[:i] ) ) for i in range(na) if sum( ta[:i] ) <= k ]\nreadbook.append( get_bcnt(k) )', 'na,nb,k = map(int, input().split())\nta = map(int, input().split())\ntb = map(int, input().split())\n\ndef get_bcnt( usek,tb=tb ):\n t = 0\n cnt = 0\n try:\n while True:\n if t + tb[cnt] > usek:\n return cnt\n else:\n t += tb[cnt]\n cnt += 1\n except:\n return len(tb)\n\nsumta = 0\nreadbook = [get_bcnt(k)] \nfor i in range(na):\n sumta += ta[i]\n if sumta > k:\n break\n if ta[i] <= k:\n readbook.append( i+1 + get_bcnt( k - sumta ) )\n\n\n\n\nprint( max(readbook) )\n ', 'na,nb,k = map(int, input().split())\nta = list(map(int, input().split()))\ntb = list(map(int, input().split()))\n \ndef get_bcnt( usek,tb=tb ):\n t = 0\n cnt = 0\n try:\n while True:\n if t + tb[cnt] > usek:\n return cnt\n else:\n t += tb[cnt]\n cnt += 1\n except:\n return len(tb)\n \nsumta = 0\nreadbook = [ i+1 + get_bcnt( k - sum( ta[:i] ) ) ) for i in range(na) if sum( ta[:i] ) <= k ]\nreadbook.append( get_bcnt(k) )', 'na,nb,k = map(int, input().split())\nta = list(map(int, input().split()))\ntb = list(map(int, input().split()))\n\na = [0]\nfor i in range(na):\n a.append( a[i] + ta[i] )\nb = [0]\nfor i in range(nb):\n b.append( b[i] + tb[i] )\n\nans, j=0, nb\nfor i in range(na + 1):\n if a[i] > k:\n break\n while True:\n if a[i] + b[j] > k:\n j -= 1\n else:\n break\n ans = max(ans, i+j)\n \nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s033426176', 's223608923', 's285402887', 's600318327', 's329926238']
[40776.0, 40528.0, 40584.0, 8884.0, 47388.0]
[75.0, 2207.0, 80.0, 25.0, 302.0]
[557, 478, 572, 496, 394]
p02623
u405660020
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int, input().split())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\n\nfrom itertools import accumulate\na_acc=list(accumulate(a))\nb_acc=list(accumulate(b))\n\ncnt=0\n\nimport bisect\nfor i in range(n):\n nokori=k-a_acc[i]\n if nokori<b[0]:\n break\n b_i=bisect.bisect_right(b_acc,nokori)\n cnt=max(cnt,(i+1)+b_i)\n print(nokori,i,b_i)\n\nprint(cnt)\n', 'n,m,k=map(int, input().split())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\n\nfrom itertools import accumulate\na_acc=list(accumulate(a))\nb_acc=list(accumulate(b))\na_acc.insert(0,0)\nb_acc.insert(0,0)\n\ncnt=0\n\nimport bisect\nfor i in range(n+1):\n nokori=k-a_acc[i]\n if nokori<0:\n break\n b_i=bisect.bisect_right(b_acc,nokori)-1\n cnt=max(cnt,i+b_i)\n \n\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s054370223', 's097303214']
[47480.0, 47336.0]
[454.0, 277.0]
[388, 422]
p02623
u406355300
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\nmin = 0\ncnt = 0\nfor i,k in enumerate(b):\n min += k\nj = i\nfor i in range(N):\n while(j > 0 and min > K):\n j -= 1\n min -= b[j]\n if(min > K):\n break\n cnt = max(cnt, i + j)\n if(i == N):\n break\n min += a[i]\nprint(cnt)\n', 'N, M, K = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nmin = 0\ncnt = 0\nfor k in b:\n min += k\nj = M\nfor i in range(N+1):\n while(j > 0 and min > K):\n j -= 1\n min -= b[j]\n if(min > K):\n break\n cnt = max(cnt, i + j)\n if(i == N):\n break\n min += a[i]\nprint(cnt)\n']
['Wrong Answer', 'Accepted']
['s509508239', 's095713288']
[40420.0, 40508.0]
[248.0, 245.0]
[366, 355]
p02623
u408262366
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nans = 0\ncost = 0\nb_i = 0\nif not (a[0] >= k and b[0] >= k):\n while 1:\n if ans >= n:\n if ans-n>=m:\n break\n _next = b[b_i]\n b_i += 1\n else:\n _next = a[ans]\n if (cost + _next) <= k:\n ans += 1\n cost += _next\n else:\n b_i -= 1\n break\n\n max_ans = ans\n if b_i == 0 or b_i == -1:\n for i in range(ans-1,-1,-1): \n ans -= 1\n cost -= a[i]\n while 1:\n if b_i >= m:\n break\n _next = b[b_i]\n if cost + _next > k:\n break\n cost += _next\n ans += 1\n b_i += 1\n max_ans = max(max_ans, ans)\n else:\n b_i += 1\n for i in range(n-1,-1,-1):\n ans -= 1\n cost -= a[i]\n while cost < k and b_i < m:\n ans += 1\n cost += b[b_i]\n b_i += 1\n max_ans = max(max_ans, ans)\n\n if a[0] <= k:\n print(max_ans)\n else:\n ans = 0\n cost = 0\n _next = 0\n while 1:\n if ans >= m:\n break\n _next = b[ans]\n if cost + _next > k:\n break\n cost += _next\n ans += 1\n print(ans)\nelse:\n print(0)', 'n,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\n\n\n\n\nans = 0\ncost = 0\nb_i = 0\nwhile cost <= k:\n ans += 1\n if ans >= n:\n cost += b[n-ans]\n b_i += 1\n else:\n cost += a[ans]\n\nmax_ans = ans\nif b_i == 0:\n for i in range(ans-1,-1,-1):\n ans -= 1\n cost -= a[i]\n while cost <= k and b_i < m:\n ans += 1\n cost += b[b_i]\n b_i += 1\n max_ans = max(max_ans, ans)\nelse:\n for i in range(n-1,-1,-1):\n ans -= 1\n cost -= a[i]\n while cost <= k and b_i < m:\n ans += 1\n cost += b[b_i]\n b_i += 1\n max_ans = max(max_ans, ans)\n \nif not a[0] >= k and b[0] >= k:\n print(max_ans)\nelse:\n print(0)', 'n,m,k = map(int,input().split())\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\n\n\n\n\nans = 0\ncost = a[0]\nb_i = 0\nif not (a[0] >= k and b[0] >= k):\n while cost <= k:\n ans += 1\n if ans >= n:\n if ans-n>=m:\n break\n cost += b[n-ans]\n b_i += 1\n else:\n cost += a[ans]\n\n max_ans = ans\n if b_i == 0:\n for i in range(ans-1,-1,-1):\n ans -= 1\n cost -= a[i]\n while cost <= k and b_i < m:\n ans += 1\n cost += b[b_i]\n b_i += 1\n max_ans = max(max_ans, ans)\n else:\n for i in range(n-1,-1,-1):\n ans -= 1\n cost -= a[i]\n while cost <= k and b_i < m:\n ans += 1\n cost += b[b_i]\n b_i += 1\n max_ans = max(max_ans, ans)\n\n print(max_ans)\nelse:\n print(0)', 'N, M, K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na, b=[0], [0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \nans, j=0, M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n ans=max(ans, i+j)\n \nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s388515193', 's759757239', 's912949761', 's878624876']
[41040.0, 42544.0, 39988.0, 47452.0]
[324.0, 289.0, 298.0, 308.0]
[1193, 834, 920, 322]
p02623
u408375121
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\ncum_a = []\ntotal = 0\nfor i in range(n):\n total += a[i]\n if total > k:\n break\n cum_a.append(total)\n \ncum_b = []\ntotal = 0\nfor j in range(m):\n total += b[j]\n if total > k:\n break\n cum_b.append(total)\nlim_a = len(cum_a)\nlim_b = len(cum_b)\nidx = 0\nans = lim_a\nfor l in range(1, lim_a + 1):\n while True:\n if k >= cum_a[-l] + cum_b[idx]:\n ans = lim_a - l + idx + 2\n else:\n idx += 1\n idx += 1\nprint(ans)\n', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ncum_a = []\ntotal = 0\nfor i in range(n):\n total += a[i]\n if total > k:\n break\n cum_a.append(total)\n \ncum_b = []\ntotal = 0\nfor j in range(m):\n total += b[j]\n if total > k:\n break\n cum_b.append(total)\nlim_a = len(cum_a)\nlim_b = len(cum_b)\nidx = 0\nans = lim_a\nfor l in range(1, lim_a + 1):\n for idx in range(lim_b):\n if k >= cum_a[-l] + cum[idx]:\n ans = max(ans, lim_a - l + idx + 2)\nprint(ans)\n', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ncum_a = []\ntotal = 0\nfor i in range(n):\n total += a[i]\n if total > k:\n break\n cum_a.append(total)\n \ncum_b = []\ntotal = 0\nfor j in range(m):\n total += b[j]\n if total > k:\n break\n cum_b.append(total)\nlim_a = len(cum_a)\nlim_b = len(cum_b)\nidx = 0\nans = lim_a\nfor l in range(1, lim_a + 1):\n while idx < lim_b:\n if k >= cum_a[-l] + cum_b[idx]:\n ans = max(ans, lim_a - l + idx + 2)\n else:\n break\n idx += 1\nans = max(ans, lim_b)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s095580879', 's435529368', 's767673446']
[40736.0, 40604.0, 40632.0]
[238.0, 196.0, 312.0]
[538, 521, 574]
p02623
u408793494
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\np_time = 0\ntime = 0\nwhile time < k:\n if len(a) > 0 and len(b) > 0:\n if a[0] >= b[0]:\n time += a[0]\n a.remove(a[0])\n else:\n time += b[0]\n b.remove(b[0])\n elif len(a) <= 0 and len(b) <= 0:\n break\n elif len(a) <= 0 < len(b):\n time += b[0]\n b.remove(b[0])\n elif len(b) <= 0 < len(a):\n time += a[0]\n a.remove(a[0])\n if time <= k:\n p_time += 1\n\nprint(p_time)\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 j in range(m):\n b.append(b[j] + B[j])\n\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s288709008', 's196315324']
[40440.0, 47540.0]
[2206.0, 284.0]
[577, 364]
p02623
u414980766
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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#include <algorithm>\n\n\n\nint main()\n{\n long long n,m,k; std::cin >> n >> m >> k;\n // long long a[n+1], b[m+1];\n std::vector<long long> a{n+1}, b{m+1};\n a[0]=0; b[0]=0;\n for (int i=1;i<n+1;i++)\n std::cin >> a[i];\n for (int i=1; i<m+1; i++)\n std::cin >> b[i];\n \n for (int i=1; i<n+1; i++)\n a[i]+=a[i-1];\n for (int i=1; i<m+1; i++)\n b[i]+=b[i-1];\n\n int ans=0, r=m;\n for (int i=0; i<n+1; i++)\n {\n if(a[i]>k) break;\n while (a[i]+b[r]>k)\n r--;\n ans = std::max({ans, i+r});\n }\n \n std::cout << ans;\n\n return 0;\n}', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn,m,k = map(int, readline().split())\na = list(map(int, readline().split()))\nb = list(map(int, readline().split()))\n\nsa = [0]*(n+1)\nsb = [0]*(m+1)\n\nfor i in range(n):\n sa[i+1] = sa[i]+a[i]\nfor i in range(m):\n sb[i+1] = sb[i]+b[i]\n\nisb=m\nans = 0\nfor isa in range(n+1):\n if sa[isa]>k:\n break\n while isb>0 and sa[isa]+sb[isb]>K:\n isb-=1\n ans = max(ans, isa+isb)\n \nprint(ans)', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn,m,k = map(int, readline().split())\na = list(map(int, readline().split()))\nb = list(map(int, readline().split()))\n\nsa = [0]*(n+1)\nsb = [0]*(m+1)\n\nfor i in range(n):\n sa[i+1] = sa[i]+a[i]\nfor i in range(m):\n sb[i+1] = sb[i]+b[i]\n\nisb=m\nans = 0\nfor isa in range(n+1):\n if sa[isa]>k:\n break\n #while isb>0 and sa[isa]+sb[isb]>k:\n while sa[isa]+sb[isb]>k:\n isb-=1\n ans = max(ans, isa+isb)\n \nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s318214925', 's670322336', 's373651099']
[8896.0, 48168.0, 48384.0]
[26.0, 192.0, 283.0]
[651, 519, 549]
p02623
u416011173
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['# -*- coding: utf-8 -*-\n\nN, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\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)\n\n\nprint(ans)\n', '# -*- coding: utf-8 -*-\n\ndef get_input() -> tuple:\n \n N, M, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n return N, M, K, A, B\n\n\ndef main(N: int, M: int, K: int, A: list, B: list) -> None:\n \n \n a, b = [0], [0]\n for i in range(N):\n a.append(a[i] + A[i])\n for j in range(M):\n b.append(b[j] + B[j])\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 \n print(ans)\n\n\nif __name__ == "__main__":\n \n N, M, K, A, B = get_input()\n\n \n main(N, M, K, A, B)\n']
['Runtime Error', 'Accepted']
['s326586538', 's221877862']
[40484.0, 47152.0]
[158.0, 229.0]
[448, 1172]
p02623
u416758623
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['\nimport sys\npin = sys.stdin.readline\npout = sys.stdout.write\nperr = sys.stderr.write\n\nN, M, K = map(int, pin().split())\nA = list(map(int, pin().split()))\nB = list(map(int, pin().split()))\na = [0]\nb = [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans = 0\nprint(a)\nprint(b)\nfor i in range(N + 1):\n \n if a[i] > K:\n break\n \n while b[M] > K - a[i]:\n M -= 1\n ans = max(ans, M + i)\nprint(ans)\n', '\nimport sys\npin = sys.stdin.readline\npout = sys.stdout.write\nperr = sys.stderr.write\n\nN, M, K = map(int, pin().split())\nA = list(map(int, pin().split()))\nB = list(map(int, pin().split()))\na = [0]\nb = [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans = 0\n\nfor i in range(N + 1):\n \n if a[i] > K:\n break\n \n while b[M] > K - a[i]:\n M -= 1\n ans = max(ans, M + i)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s176250721', 's256471892']
[55648.0, 49236.0]
[335.0, 278.0]
[566, 549]
p02623
u418149936
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['for i in range(1, N + 1):\n A_ls[i] += A_ls[i - 1]\nfor i in range(1, M + 1):\n B_ls[i] += B_ls[i - 1]\n\nb_cnt, rst = M, 0\nfor a_cnt in range(N + 1):\n if A_ls[a_cnt] > K:\n break\n while A_ls[a_cnt] + B_ls[b_cnt] > K:\n b_cnt -= 1\n rst = max(rst, a_cnt + b_cnt)\nprint(rst)', "N, M, K = map(int, input().split(' '))\nA_ls = [0] + list(map(int, input().split(' ')))\nfor i in range(N):\n A_ls[i + 1] += A_ls[i]\nB_ls = [0] + list(map(int, input().split(' ')))\nfor i in range(M):\n B_ls[i + 1] = B_ls[i]\n\nb_cnt, rst = M, 0 \nfor a_cnt in range(N + 1):\n if A_ls[a_cnt] > K:\n break\n while A_ls[a_cnt] + B_ls[b_cnt] > K and b_cnt >= 0:\n b_cnt -= 1\n rst = max(rst, a_cnt + b_cnt)\nprint(rst)", "N, M, K = map(int, input().split(' '))\nA_ls = [0] + list(map(int, input().split(' ')))\nfor i in range(N):\n A_ls[i + 1] += A_ls[i]\nB_ls = [0] + list(map(int, input().split(' ')))\nfor i in range(M):\n B_ls[i + 1] += B_ls[i]\nb_cnt, rst = M, 0\nfor a_cnt in range(N + 1):\n if A_ls[a_cnt] > K:\n break\n while A_ls[a_cnt] + B_ls[b_cnt] > K and b_cnt >= 0:\n b_cnt -= 1\n rst = max(rst, a_cnt + b_cnt)\nprint(rst)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s531424687', 's650926755', 's981236402']
[9072.0, 45168.0, 45208.0]
[27.0, 232.0, 293.0]
[294, 430, 429]
p02623
u425834921
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0]\nb = [0]\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 b[i] > K - a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0]\nb = [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n \nans = 0\nj = M\nfor 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']
['s725976794', 's456356589']
[47652.0, 47280.0]
[2207.0, 289.0]
[335, 335]
p02623
u430536466
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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):\nif a[i] > K:\nbreak\nwhile b[j] > K - a[i]:\nj -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\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']
['s098965553', 's607615755']
[8924.0, 47428.0]
[21.0, 281.0]
[326, 335]
p02623
u430726059
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 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 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', 'Runtime Error', 'Accepted']
['s176333968', 's816104122', 's982211002']
[47496.0, 47428.0, 47368.0]
[319.0, 306.0, 312.0]
[314, 310, 345]
p02623
u435480265
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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())\nln = list(map(int, input().split()))\nlm = list(map(int, input().split()))\ndef sub(l,k):\n res = 0\n for i in l:\n if k >= i:\n k -= i\n res += 1\n else:\n return k,res\n return k,res\n \ndef main(n,m,k,ln,lm):\n nk = sum(ln)\n mk = sum(lm)\n if k>=nk+mk:\n return n+m\n elif k>nk:\n ik, res = sub(lm, k-nk)\n res += n\n startn = n - 1\n startm = res - 1\n else:\n ik, res = sub(ln, k)\n startn = res - 1\n ik, res2 = sub(lm, ik)\n res += res2\n startm = res2\n \n ires = res\n for i in range(startn,-1,-1):\n ik += ln[i]\n ik, delta = sub(lm[startm:], ik)\n startm += delta\n ires = ires - 1 + delta\n res = max(res, ires)\n return res\n\nmain(n,m,k,ln,lm)', "n,m,k = map(int, input().split())\nln = list(map(int, input().split()))\nlm = list(map(int, input().split()))\n\ndef csum(l,ll):\n s = 0\n res = [0] * ll\n for i in range(ll):\n s += l[i]\n res[i] = s\n return res\n\ncsln = csum(ln,n)\ncslm = csum(lm,m)\n\nimport numpy as np\n\nlk = [k-x for x in csln if k-x >=0]\nres = np.searchsorted(np.array(cslm), np.array(lk), side='right').\nrmax = 0\nfor i,j in zip(range(1,len(lk)+1), res):\n rmax = max(rmax, i+j)\nprint(int(rmax))", "n,m,k = map(int, input().split())\nln = list(map(int, input().split()))\nlm = list(map(int, input().split()))\n\ndef csum(l,ll):\n s = 0\n res = [0] * ll\n for i in range(ll):\n s += l[i]\n res[i] = s\n return res\n\ncsln = csum(ln,n)\ncslm = csum(lm,m)\n\nimport numpy as np\n\nlk = [k] + [k-x for x in csln if k-x >=0]\nres = np.searchsorted(np.array(cslm), np.array(lk), side='right')\nrmax = 0\nfor i,j in zip(range(len(lk)+1), res):\n rmax = max(rmax, i+j)\nprint(rmax)"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s183246923', 's695470160', 's612764472']
[40604.0, 8872.0, 70628.0]
[2206.0, 26.0, 427.0]
[853, 483, 481]
p02623
u436519884
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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.insert(0,0)\nb.insert(0,0)\nj=1\nwhile j<=m and b[j]+b[j-1]<=k:\n b[j]+=b[j-1]\n j+=1\n \n\nj-=1\nbooks=j\ni=1\nwhile i<n+1:\n while j>0 and a[i]+b[j]>k:\n j-=1\n if(j>=0) and a[i]+b[j]<=k:\n books=max(books,j+i)\n a[i]+=a[i-1]\n i+=1\n else:\n break\nprint(books)\n \n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\na.insert(0,0)\nb.insert(0,0)\nj=1\nwhile j<=m and b[j]+b[j-1]<=k:\n b[j]+=b[j-1]\n j+=1\n \n\nj-=1\nbooks=j\ni=1\nwhile i<n:\n while j>0 and a[i]+b[j]>k:\n j-=1\n if(j>=0) and a[i]+b[j]<=k:\n books=max(books,j+i)\n a[i]+=a[i-1]\n else:\n break\nprint(books)\n ', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\na.insert(0,0)\nb.insert(0,0)\nj=1\nwhile j<=m and b[j]+b[j-1]<=k:\n b[j]+=b[j-1]\n j+=1\n \n\nj-=1\nbooks=j\n#print(books,b)\n\ni=1\nwhile i<n+1:\n a[i]+=a[i-1]\n while j>=0 and a[i]+b[j]>k:\n j-=1\n if(j!=-1) and a[i]+b[j]<=k:\n books=max(books,j+i)\n \n \n i+=1\n #print(books,b[:j+1],a[:i])\n else:\n break\nprint(books)\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s734253249', 's957491945', 's715177035']
[40496.0, 42204.0, 42168.0]
[326.0, 2206.0, 361.0]
[368, 356, 426]
p02623
u439676056
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nN, M, K = map(int, input().split())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\n\n\n#N, M, K = 3, 4, 730\n#A_list = [60, 90, 120]\n#B_list = [80, 150, 80, 150]\n\n\nA_list.insert(0, 0)\nB_list.insert(0, 0)\nB_cumsum = np.cumsum(B_list)\n\ntime = B_cumsum[-1]\nans, j = 0, M\n\nfor i in range(N+1):\n while (j > 0 and time > K):\n j -= 1\n time -= B_cumsum[j]\n if (time > K):\n break\n ans = max(ans, i+j)\n time += A_list[i]\n\nprint(ans)\n', '\nN, M, K = map(int, input().split())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\n\n\nA_list.insert(0, 0)\nB_list.insert(0, 0)\nB_cumsum = np.cumsum(B_list)\n\ntime = B_cumsum[-1]\nans, j = 0, M\n\nfor i in range(N+1):\n if (time > K):\n break\n while (j > 0 and time > K):\n time -= B_list[j]\n j -= 1\n\n ans = max(ans, i+j)\n time += A_list[i]\n\nprint(ans)\n', 'import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nN, M, K = map(int, input().split())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\n\n\nA_list.insert(0, 0)\nB_list.insert(0, 0)\nB_cumsum = np.cumsum(B_list)\n\ntime = B_cumsum[-1]\nans, j = 0, M\n\nfor i in range(N+1):\n if (time > K):\n break\n while (j > 0 and time > K):\n time -= B_list[j]\n j -= 1\n\n ans = max(ans, i+j)\n time += A_list[i]\n\nprint(ans)', 'N, M, K = map(int, input().split())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\n\n\nf = open(\'b20.txt\')\ndata = f.readlines()\ndata = [d.replace("\\n", "").split(" ") for d in data]\nN, M, K = map(int, data[0])\nA_list = list(map(int, data[1]))\nB_list = list(map(int, data[2]))\n\nA_list.insert(0, 0)\nB_list.insert(0, 0)\nB_cumsum = np.cumsum(B_list)\n\ntime = B_cumsum[-1]\nans, j = 0, M\n\nB_list[j]\nfor i in range(N+1):\n if (time > K):\n break\n while (j > 0 and time > K):\n time -= B_list[j]\n j -= 1\n \n ans = max(ans, i+j)\n time += A_list[i]\n\nprint(ans)', 'import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nN, M, K = map(int, input().split())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\n\n\n#N, M, K = 3, 4, 730\n#A_list = [60, 90, 120]\n#B_list = [80, 150, 80, 150]\n\n\nA_list.insert(0, 0)\nB_list.insert(0, 0)\nB_cumsum = np.cumsum(B_list)\n\ntime = B_cumsum[-1]\nans, j = 0, M\n\nfor i in range(N+1):\n while (j > 0 and time > K):\n j -= 1\n time -= B_cumsum[j]\n if (time > K):\n break\n ans = max(ans, i+j)\n time += A_list[i]\n\nprint(ans)\n', '\nimport sys\nimport numpy as np\ninput = sys.stdin.readline\n\nN, M, K = map(int, input().split())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\n\n\nA_list.insert(0, 0)\nB_list.insert(0, 0)\nA_cumsum = np.cumsum(A_list)\nB_cumsum = np.cumsum(B_list)\n\ntime = B_cumsum[-1]\nans, j = 0, M\n\n\n\nfor i in range(N+1):\n if A_cumsum[i] > K:\n break\n while B_cumsum[j] > K - A_cumsum[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s142936493', 's167678407', 's356577359', 's786390039', 's891521486', 's221512611']
[59348.0, 40548.0, 59092.0, 41188.0, 58840.0, 59220.0]
[375.0, 110.0, 365.0, 115.0, 375.0, 515.0]
[546, 412, 468, 614, 546, 465]
p02623
u440613652
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int,input().split())\n\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\n\na_pre,b_pre=[0],[0]\n\nfor i in range(n):\n\ta_pre.append(a_pre[i]+a[i])\n\nfor i in range(m):\n\tb_pre.append(b_pre[i]+b[i])\n\nans,j=0,m\nfor i in range(n+1):\n\tif a_pre[i]>k:\n\t\tbreak\n\twhile b[j]>k-a[i]:\n\t\tj-=1\n\n\tans=max(ans,i+j)\n\nprint(ans)\n', 'n,m,k=map(int,input().split())\n\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\n\na_pre,b_pre=[0],[0]\n\nfor i in range(n):\n\ta_pre.append(a_pre[i]+a[i])\n\nfor i in range(m):\n\tb_pre.append(b_pre[i]+b[i])\n\nans,j=0,m\nfor i in range(n+1):\n\tif a_pre[i]>k:\n\t\tbreak\n\twhile b_pre[j]>k-a_pre[i]:\n\t\tj-=1\n\n\tans=max(ans,i+j)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s291734250', 's639709290']
[47404.0, 47660.0]
[189.0, 276.0]
[332, 340]
p02623
u440975163
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na,b=[0],[0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\nprint(a)\nprint(b)\nans,j=0,m\nfor i in range(n+1):\n if a[i]>k:\n break\n while b[j]>k-a[i]:\n j-=1\n ans=max(ans,i+j)\nprint(ans)', 'n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\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)']
['Wrong Answer', 'Accepted']
['s187947173', 's188678966']
[54460.0, 47460.0]
[361.0, 298.0]
[341, 323]
p02623
u444444641
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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(input().split())\nB = list(input().split())\n\na=0;b=0\ncnt=0\nwhile a < len(A) and b < len(B) and K > 0:\n\ta_ = A[a]\n\tb_ = B[b]\n \n if a_ > K and b_ > K:\n break\n \n if a_ < b_ and a_ <= K:\n\t\tcnt += 1\n\t\tK -= a_\n\t\tA.pop(0)\n\telif a_ >= b_ and b_ <= K:\n cnt += 1\n K -= b_\n B.pop(0)\n \nprint(cnt) \n ', 'N, M, K = map(int, input().split())\nA = list(input().split())\nB = list(input().split())\n\na=0;b=0\ncnt=0\nwhile a < len(A) and b < len(B) and K > 0:\n a_ = A[a]\n b_ = B[b]\n \n if a_ > K and b_ > K:\n break\n \n if a_ < b_ and a_ <= K:\n cnt += 1\n\tK -= a_\n a += 1\n elif a_ >= b_ and b_ <= K:\n cnt += 1\n K -= b_\n b += 1\n \nprint(cnt) \n', 'a=0;b=0\ncnt=0\nwhile a < len(A) and b < len(B) and K > 0:\n\ta_ = A[a]\n\tb_ = B[b]\n \n if a_ > K and b_ > K:\n break\n \n if a_ < b_ and a_ <= K:\n\t\tcnt += 1\n\t\tK -= a_\n a += 1\n\telif a_ >= b_ and b_ <= K:\n cnt += 1\n K -= b_\n b += 1\n \nprint(cnt) ', 'N, M, K = map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int,input().split()))\n\na=0;b=0\ncnt=0\nwhile a < len(A) and b < len(B) and K > 0:\n a_ = A[a]\n b_ = B[b]\n print(a_, b_,K)\n \n if a_ > K and b_ > K:\n break\n \n if a_ < b_ and a_ <= K:\n cnt += 1\n K -= a_\n a += 1\n elif a_ >= b_ and b_ <= K:\n cnt += 1\n K -= b_\n b += 1\n \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]\nans = 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\nj = m\n\nfor i in range(n + 1):\n if A[i] > k:\n break\n while A[i] + B[j] > k:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s219843448', 's244680031', 's325851974', 's337414258', 's055070452']
[9004.0, 8988.0, 8960.0, 40616.0, 47680.0]
[22.0, 21.0, 27.0, 379.0, 294.0]
[377, 360, 282, 431, 366]
p02623
u445624660
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['package main\nimport (\n\t"bufio"\n\t"fmt"\n\t"os"\n\t"strconv"\n)\n\nvar sc = bufio.NewScanner(os.Stdin)\nvar out = bufio.NewWriter(os.Stdout)\n\nfunc main(){\n\tbuf := make([]byte, 1024*1024)\n\tsc.Buffer(buf, bufio.MaxScanTokenSize)\n\tsc.Split(bufio.ScanWords)\n\tdefer out.Flush()\n\tN, M, K := nextInt(), nextInt(), nextInt()\n\tA := append([]int{0}, nextInts(N)...)\n\tB := append([]int{0}, nextInts(M)...)\n\tfor i:=1; i<=N; i++{\n\t\tA[i] += A[i-1]\n\t}\n\tfor i:=1; i<=M; i++{\n\t\tB[i] += B[i-1]\n\t}\n\tans := 0\n\tfor i:=0; i<=N; i++{\n\t\trest := K-A[i]\n\t\tif rest < 0{\n\t\t\tbreak\n\t\t}\n\t\t// golangでupper_boundどうやるんだ??????・\n\t\t/// bidx := max(0, sort.Search(len(B), func(j int)bool{return rest<=B[j]}))\n\t\t// bidx := sort.Search(len(B), func(j int)bool{return rest<=B[j]})-1\n\t\t// bidx := sort.SearchInts(B, rest)\n\t\t// わからんので仕方なく手書き\n\t\tleft, right := -1, len(B)\n\t\tfor right - left > 1{\n\t\t\tmid := (left+right)/2\n\t\t\tif rest-B[mid]>=0{\n\t\t\t\tleft = mid\n\t\t\t}else{\n\t\t\t\tright = mid\n\t\t\t}\n\t\t}\n\t\tbidx := left\n\t\tans = max(ans, i+bidx)\n\t}\n\tfmt.Fprintln(out, ans)\n}\n\nfunc min(a, b int) int {\n\tif a<b{\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a<b{\n\t\treturn b\n\t}\n\treturn a\n}\nfunc next() string {\n\tsc.Scan()\n\treturn sc.Text()\n}\n\nfunc nextInt() int {\n\ta, _ := strconv.Atoi(next())\n\treturn a\n}\n\nfunc nextInts(n int) []int{\n\tret := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tret[i] = nextInt()\n\t}\n\treturn ret\n}\n\nfunc nextStrings(n int) []string {\n\tret := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tret[i] = next()\n\t}\n\treturn ret\n}\n\nfunc chars(s string) []string {\n\tret := make([]string, len([]rune(s)))\n\tfor i, v := range []rune(s) {\n\t\tret[i] = string(v)\n\t}\n\treturn ret\n}\n', 'n, m, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\nb = [0] + list(map(int, input().split()))\nfor i in range(1, n + 1):\n a[i] += a[i - 1]\nfor i in range(1, m + 1):\n b[i] += b[i - 1]\n\n\ndef search(arr, x):\n l, r = 0, len(arr)\n while abs(r - l) > 1:\n mid = (l + r) // 2\n print(l, r, mid)\n if arr[mid] <= x:\n l = mid\n else:\n r = mid\n return l\n\n\narrr = [0, 80, 230, 310, 460]\nt = 90\nti = search(arrr, t)\n\nans = 0\nfor i in range(len(a)):\n rest = k - a[i]\n if rest < 0:\n break\n bidx = search(b, rest)\n if bidx == m:\n break\n ans = max(ans, i + bidx)\nprint(ans)', 'n, m, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\nb = [0] + list(map(int, input().split()))\nfor i in range(1, n + 1):\n a[i] += a[i - 1]\nfor i in range(1, m + 1):\n b[i] += b[i - 1]\n\n\ndef search(arr, x):\n l, r = -1, len(arr)\n while abs(r - l) > 1:\n mid = (l + r) // 2\n print(l, r, mid)\n if arr[mid] <= x:\n l = mid\n else:\n r = mid\n return l\n\n\narrr = [0, 80, 230, 310, 460]\nt = 90\nti = search(arrr, t)\n\nans = 0\nfor i in range(len(a)):\n rest = k - a[i]\n if rest < 0:\n break\n bidx = search(b, rest)\n ans = max(ans, i + bidx)\nprint(ans)', 'n, m, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\nb = [0] + list(map(int, input().split()))\nfor i in range(1, n + 1):\n a[i] += a[i - 1]\nfor i in range(1, m + 1):\n b[i] += b[i - 1]\n\n\ndef search(arr, x):\n l, r = -1, len(arr)\n while abs(r - l) > 1:\n mid = (l + r) // 2\n if arr[mid] <= x:\n l = mid\n else:\n r = mid\n return l\n\n\nans = 0\nfor i in range(len(a)):\n rest = k - a[i]\n if rest < 0:\n break\n bidx = search(b, rest)\n if bidx == -1 or bidx == len(b):\n continue\n ans = max(ans, i + bidx)\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s281290356', 's893990176', 's916230580', 's561025209']
[9004.0, 71344.0, 74568.0, 42252.0]
[29.0, 2266.0, 2279.0, 791.0]
[1679, 672, 641, 611]
p02623
u446711904
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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])\nfor i in range(m):\n b.append(b[i]+B[i])\n \nc=0\nidx=m\n\nfor i in range(n+1):\n while 1:\n if idx<0:\n break\n if a[i]+b[idx]>k:\n print(a[i]+b[idx])\n idx-=1\n continue\n else:\n c=max(i+idx,c)\n break\nelse:\n print(c)', 'n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na=[0]\nb=[0]\n\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\n \nc=0\nidx=m\n\nfor i in range(n+1):\n while 1:\n if idx<0:\n break\n if a[i]+b[idx]>k:\n idx-=1\n continue\n else:\n c=max(i+idx,c)\n break\nelse:\n print(c)']
['Wrong Answer', 'Accepted']
['s199063082', 's490467136']
[47368.0, 47376.0]
[359.0, 292.0]
[457, 426]
p02623
u450288159
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
["# -*- coding: utf-8 -*-\n\n\ndef main():\n n, m, k = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n a = A[0]\n A2 = [a]\n b = B[0]\n B2 = [b]\n for i in range(1, n):\n a += A[i]\n A2.append(a)\n\n for i in range(1, m):\n b += B[i]\n B2.append(b)\n max = -2\n for ia, aa in enumerate(A2):\n for ib, bb in enumerate(B2):\n if aa + bb > k:\n break\n if ia + ib > max:\n\n max = ia + ib\n print(max + 2)\n\n\ndef answer():\n N, M, K = map(int, input().split())\n\n\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n a, b = [0], [0]\n for i in range(N):\n a.append(a[i] + A[i])\n for i in range(M):\n b.append(b[i] + B[i])\n\n ans, j = 0, M\n for i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n print(ans)\nif __name__ == '__main__':\n answer()", "# -*- coding: utf-8 -*-\n\n\n\n\n# A = list(map(int, input().split()))\n# B = list(map(int, input().split()))\n# a = A[0]\n# A2 = [a]\n# b = B[0]\n# B2 = [b]\n\n# a += A[i]\n# A2.append(a)\n# \n\n# b += B[i]\n# B2.append(b)\n# max = -2\n\n# for ib, bb in enumerate(B2):\n\n# break\n# if ia + ib > max:\n# \n# max = ia + ib\n# print(max + 2)\n# \n\ndef answer():\n N, M, K = map(int, input().split())\n\n\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n a, b = [0], [0]\n for i in range(N):\n a.append(a[i] + A[i])\n for i in range(M):\n b.append(b[i] + B[i])\n\n ans, j = 0, M\n for i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\n print(ans)\nif __name__ == '__main__':\n answer()"]
['Runtime Error', 'Accepted']
['s392235308', 's953429087']
[9128.0, 47332.0]
[26.0, 229.0]
[1050, 1088]
p02623
u454866890
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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,l = map(int,input().split(" "))\nNs = input().split(" ")\nN = [int (n) for n in Ns]\nMs = input().split(" ")\nM = [int(n) for n in Ms]\n#print(n,m,l)\n#print(N,M)\ni = 0\nj = 0\ntotal = 0\ncnt = 0\nwhile total <= l:\n if N[i] <= M[j]:\n total = total + N[i]\n i = i+1\n cnt = cnt +1\n else:\n total = total + M[j]\n j = j+1\n cnt = cnt +1\nprint(cnt)', 'N,M,K = list(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 j in range(M):\n b.append(b[j]+B[j])\nans = 0\n#print(a,b,N+1)\nj = M\nfor i in range(N+1):\n if a[i] > K:\n break\n\n while K - a[i] < b[j]:\n j = j-1\n ans = max(ans,i+j)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s892285426', 's876996692']
[55284.0, 47496.0]
[183.0, 284.0]
[355, 351]
p02623
u455354923
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['#import sys\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\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])\nans = 0\nl = M\nfor k in range(N+1):\n if a[k] > K:\n break:\n while b[l] + a[k] > K:\n l -= 1\n ans = max(ans,k+l)\nprint(ans)\n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\ntime = 0\nwhile time < K:\n if not A:\n ans += 1\n if time + B[0] > K:\n break\n time += B[0]\n B.pop(0)\n elif not B:\n ans += 1\n if time + A[0]> K:\n break\n time += A[0]\n A.pop(0)\n elif A[0] > K or B[0] > K:\n break\n elif A[0] == B[0]:\n if A[1] > B[1]:\n if time + B[0] > K:\n break\n time += B[0]\n ans += 1\n B.pop(0)\n elif A[1] < B[1]:\n if time + A[0] > K:\n break\n time += B[0]\n ans += 1\n A.pop(0)\n elif A[0] > B[0] :\n if time + B[0] > K:\n break\n time += B[0]\n ans += 1\n B.pop(0)\n elif A[0] < B[0]:\n if time + A[0] > K:\n break\n time += B[0]\n ans += 1\n A.pop(0)\nprint(ans)\n', '#import sys\nN,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])\nans = 0\nl = M\nfor k in range(N+1):\n if a[k] > K:\n break:\n while b[l] > K - a[k]:\n l -= 1\n ans = max(ans,k+l)\nprint(ans)\n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\ntime = 0\nwhile time < K:\n if not A:\n ans += 1\n time += B[0]\n B.pop(0)\n elif not B:\n ans += 1\n time += A[0]\n A.pop(0)\n elif A[0] = B[0]:\n if A[1] > B[1]:\n time += B[0]\n ans += 1\n B.pop(0)\n else A[1] < B[1]:\n time += B[0]\n ans += 1\n A.pop(0)\n elif A[0] > B[0] :\n time += B[0]\n ans += 1\n B.pop(0)\n elif A[0] < B[0]:\n time += B[0]\n ans += 1\n A.pop(0)\nprint(ans)\n', 'import sys\nN,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[i]+B[i])\nans = 0\nl = M\nfor k in range(N+1):\n if a[k] > K:\n break:\n while b[l] + a[k] > K:\n j -= 1\n ans = max(ans,k+j)\nprint(ans) \n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\ntime = 0\nwhile time < K:\n if not A:\n ans += 1\n time += B[0]\n B.pop(0)\n elif not B:\n ans += 1\n time += A[0]\n A.pop(0)\n elif A[0] == B[0]:\n if A[1] > B[1]:\n time += B[0]\n ans += 1\n B.pop(0)\n else A[1] < B[1]:\n time += B[0]\n ans += 1\n A.pop(0)\n elif A[0] > B[0] :\n time += B[0]\n ans += 1\n B.pop(0)\n elif A[0] < B[0]:\n time += B[0]\n ans += 1\n A.pop(0)\nprint(ans)\n', '#import sys\nN,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[i]+B[i])\nans = 0\nl = M\nfor k in range(N+1):\n if a[k] > K:\n break:\n while b[l] + a[k] > K:\n l -= 1\n ans = max(ans,k+l)\nprint(ans)\n', 'N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\ntime = 0\nwhile time < K:\n if not A:\n ans += 1\n if time + B[0]:\n break\n time += B[0]\n B.pop(0)\n elif not B:\n ans += 1\n if time + A[0]:\n break\n time += A[0]\n A.pop(0)\n elif A[0] > K or B[0] > K:\n break\n elif A[0] == B[0]:\n if A[1] > B[1]:\n if time + B[0]:\n break\n time += B[0]\n ans += 1\n B.pop(0)\n elif A[1] < B[1]:\n if time + A[0]:\n break\n time += B[0]\n ans += 1\n A.pop(0)\n elif A[0] > B[0] :\n if time + B[0]:\n break\n time += B[0]\n ans += 1\n B.pop(0)\n elif A[0] < B[0]:\n if time + A[0]:\n break\n time += B[0]\n ans += 1\n A.pop(0)\nprint(ans)\n', '#import sys\nN,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])\nans = 0\nl = M\nfor k in range(N+1):\n if a[k] > K:\n break\n while b[l] > K - a[k]:\n l -= 1\n ans = max(ans,k+l)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s071528214', 's166750424', 's322750788', 's526192119', 's663763471', 's751265318', 's835588767', 's968549703', 's873200760']
[8992.0, 40052.0, 9048.0, 8988.0, 9016.0, 9012.0, 8916.0, 40056.0, 47608.0]
[24.0, 2206.0, 28.0, 24.0, 28.0, 25.0, 25.0, 2206.0, 290.0]
[357, 985, 357, 648, 357, 649, 357, 962, 356]
p02623
u459419927
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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=list(map(int,input().split()))\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nbka=[0]*N\nbkb=[0]*M\nbka[0]=A[0]\nbkb[0]=B[0]\n\nfor i in range(1,N):\n bka[i]+=bka[i-1]+A[i]\nfor j in range(1,M):\n bkb[j]+=bkb[j-1]+B[j]\nans=bisect.bisect_left(bka,K)\nfor i in range(N):\n count=i+1\n k=K-bka[i]\n if k<0:continue\n c = bisect.bisect_left(bkb,k)\n if c!=M:\n if bkb[c]==k:\n c+=count+1\n else:c+=count\n\n # print(bkb,k,c,count)\n ans=max(ans,c)\nprint(ans)', 'import bisect\nN,M,K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nbka=[0]*N\nbkb=[0]*M\nbka[0]=A[0]\nbkb[0]=B[0]\n\nfor i in range(1,N):\n bka[i]+=bka[i-1]+A[i]\nfor j in range(1,M):\n bkb[j]+=bkb[j-1]+B[j]\nans=0\nc=bisect.bisect_left(bkb,K)\nif c != M:\n if bkb[c] == K:\n c +=+ 1\nans = max(ans, c)\nfor i in range(N):\n count=i+1\n k=K-bka[i]\n if k<0:continue\n c = bisect.bisect_left(bkb,k)\n b=c\n if c!=M:\n if bkb[c]==k:\n c+=count+1\n else:c+=count\n else:c+=count\n ans=max(ans,c)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s650824533', 's824407206']
[47300.0, 48976.0]
[386.0, 399.0]
[521, 592]
p02623
u463602788
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['#n = int(input())\nn,m,k = [int(z) for z in input().split()]\na = [int(z) for z in input().split()]\nb = [int(z) for z in input().split()]\ntime = 0\ni = j = 0\nwhile (time<=k and i<n and j<m):\n if (a[i]>b[j]):\n if (time+a[i]<=k):\n time += a[i]\n i+=1\n else:\n break\n else:\n if (time+b[j]<=k):\n time += b[j]\n j+=1\n else:\n break\nwhile (i<n and time<=k):\n if (time+a[i]<=k):\n time += a[i]\n i+=1\n else:\n break\nwhile (j<n and time<=k):\n if (time+b[j]<=k):\n time += b[j]\n j+=1\n else:\n break\nprint(i+j)\n', "import sys\nimport bisect\nimport itertools\nimport collections\nimport fractions\nimport heapq\nimport math\nfrom operator import mul\nfrom functools import reduce\nfrom functools import lru_cache\n\n\ndef solve():\n readline = sys.stdin.buffer.readline\n mod = 10 ** 9 + 7\n N, M, K = map(int, readline().split())\n A = list(map(int, readline().split()))\n B = list(map(int, readline().split()))\n\n\n nowtime = 0\n\n Asum = [0]\n Bsum = [0]\n tmp = 0\n for a in A:\n tmp += a\n Asum.append(tmp)\n tmp = 0\n for b in B:\n tmp += b\n Bsum.append(tmp)\n\n maxbooks = 0\n before = M\n bcount = M\n for acount in range(N+1):\n if Asum[acount] > K:\n continue\n while K < Asum[acount] + Bsum[bcount]:\n bcount -= 1\n maxbooks = max(maxbooks, acount+bcount)\n\n print(maxbooks)\n\nif __name__ == '__main__':\n solve()\n"]
['Runtime Error', 'Accepted']
['s219847187', 's227329123']
[39744.0, 49392.0]
[252.0, 219.0]
[755, 893]
p02623
u469254913
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['# import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\n\n\ndef main():\n N,M,K = map(int,input().split())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n\n a = 0\n b = 0\n\n time = 0\n res = 0\n\n isAexist = True\n isBexist = True\n\n for i in range(N+M+1):\n if isAexist:\n tA = A[a]\n else:\n tA = 10 ** 9 + 1\n if isBexist:\n tB = B[b]\n else:\n tB = 10 ** 9 + 1\n if (tA <= tB) & isAexist:\n if time + tA <= K:\n time += tA\n a += 1\n res += 1\n if a == N:\n isAexist = False\n elif (tA >= tB) & isBexist:\n if time + tB <= K:\n time += tB\n b += 1\n res += 1\n if b == M:\n isBexist = False\n print(res,time,a,b)\n if isAexist:\n if time + A[a] > K:\n isAexist = False\n if isBexist:\n if time + B[b] > K:\n isBexist = False\n if (not isAexist) & (not isBexist):\n break\n\n print(res)\n\n\n\nmain()\n', '# import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n\n\n\ndef main():\n N,M,K = map(int,input().split())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n\n sumA = [0] * (N+1)\n sumB = [0] * (M+1)\n\n for i in range(1,N+1):\n sumA[i] = sumA[i-1] + A[i-1]\n\n for i in range(1,M+1):\n sumB[i] = sumB[i-1] + B[i-1]\n\n for i in range(M,-1,-1):\n if sumB[i] <= K:\n endB = i\n break\n\n for i in range(N,-1,-1):\n if sumA[i] <= K:\n endA = i\n break\n\n res = 0\n\n for i in range(0,endA+1):\n for j in range(endB,-1,-1):\n if sumA[i] + sumB[j] <= K:\n endB = j\n res = max(res,i+j)\n break\n\n print(res)\n\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s017794776', 's606992505']
[41664.0, 47760.0]
[635.0, 288.0]
[1265, 871]
p02623
u471503862
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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_max = 0\nsum = 0\nfor i in range(n):\n sum += A[i]\n if sum > k:\n sum -= A[i]\n break\n a_max += 1\n \nans = a_max\nkotae =ans\nj = 0\n\nprint(a_max, 0)\nfor i in range(m):\n sum += B[i]\n ans += 1\n while sum > k and j < a_max:\n sum -= A[a_max-1-j]\n ans -= 1\n j += 1\n if sum > k:\n print(kotae)\n exit()\n kotae = max(kotae, ans)\n if a_max-j == 0:\n break\n \nprint(kotae)\n \n \n \n ', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na_max = 0\nsum = 0\nfor i in range(n):\n sum += A[i]\n if sum > k:\n sum -= A[i]\n break\n a_max += 1\n \nans = a_max\nkotae =ans\nj = 0\n\n\nfor i in range(m):\n sum += B[i]\n ans += 1\n while sum > k and j < a_max:\n sum -= A[a_max-1-j]\n ans -= 1\n j += 1\n if sum > k:\n print(kotae)\n exit()\n kotae = max(kotae, ans)\n\n \nprint(kotae)\n \n \n \n ']
['Wrong Answer', 'Accepted']
['s819207974', 's526498446']
[40412.0, 40624.0]
[322.0, 299.0]
[513, 470]
p02623
u473291366
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\nSUM_A=[0 for _ in range(N+1)]\nfor i in range(N):\n SUM_A[i+1] = A[i] + SUM_A[i]\n if SUM_A[i+1] > K:\n N=i\n break\n\nSUM_B=[0 for _ in range(M+1)]\nfor i in range(M):\n SUM_B[i+1] = B[i] + SUM_B[i]\n if SUM_B[i+1] > K:\n M=i\n break\n\nprint(N,M)\ncnt = 0\nfor i in range(N+1):\n for j in range(M+1):\n if SUM_A[i]+SUM_B[j] <= K:\n if i+j > cnt:\n cnt = i+j\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()))\nSUM_A=[0 for _ in range(N+1)]\nfor i in range(N):\n SUM_A[i+1] = A[i] + SUM_A[i]\n if SUM_A[i+1] > K:\n N=i\n break\n\nSUM_B=[0 for _ in range(M+1)]\nfor i in range(M):\n SUM_B[i+1] = B[i] + SUM_B[i]\n if SUM_B[i+1] > K:\n M=i\n break\n\ncnt = N\nfor i in range(N+1)[::-1]:\n V=K-SUM_A[i]\n j = cnt-i\n while j < M+1 and SUM_B[j] <= V:\n j += 1\n j-=1\n if i+j > cnt:\n cnt = i+j\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s893745440', 's297408801']
[40812.0, 42688.0]
[2207.0, 338.0]
[563, 542]
p02623
u474423089
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['import sys\ninput = sys.stdin.readline\nfrom itertools import accumulate\n\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0]+list(accumulate(A))\nb = [0]+list(accumulate(B))\nans,j = 0,M\nfor i in range(N+1):\n if i > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)', 'import sys\nfrom itertools import accumulate\ninput = sys.stdin.readline\n\nN,M,K=map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nA_acc = list(accumulate(A))\nB_acc = list(accumulate(B))\na = 0\nb = 0\nans = 0\ndeep = ""\nfor n,z in enumerate(zip(A_acc,B_acc)):\n i,j = z\n if i < j and i <= K:\n deep = \'A\'\n elif j <= K:\n deep = \'B\'\n else:\n break\n ans += 1\nif deep == \'A\':\n K -= A_acc[n]\n s = B\nelse:\n K -= B_acc[n]\n s = A\nfor i in s:\n if K >= i:\n ans += 1\n K -= i\n else:\n break\nprint(ans)', 'import sys\ninput = sys.stdin.readline\nfrom itertools import accumulate\n\nN,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0]+list(accumulate(A))\nb = [0]+list(accumulate(B))\nans,j = 0,M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s132367956', 's877901072', 's739195011']
[49076.0, 49032.0, 49056.0]
[275.0, 217.0, 234.0]
[367, 599, 370]
p02623
u475402977
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\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):\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):\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, 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', 'Accepted']
['s047536118', 's849669423', 's569818497']
[47388.0, 8752.0, 47336.0]
[362.0, 29.0, 293.0]
[347, 338, 354]
p02623
u475546258
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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):\nif a[i] > K:\nbreak\nwhile b[j] > K - a[i]:\nj -= 1\nans = max(ans, i + j)\nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s337723241', 's934920686']
[8896.0, 47544.0]
[29.0, 282.0]
[326, 345]
p02623
u476674874
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nfrom collections import deque\ndef main():\n N, M, K = map(int, input().split())\n A = deque(list(map(int, input().split())))\n B = deque(list(map(int, input().split())))\n \n cost = K\n count = 0\n while True:\n if len(A) ==0 and len(B) == 0:\n break\n elif len(A) == 0:\n cost -= B.popleft()\n elif len(B) == 0:\n cost -= A.popleft()\n\n else:\n a = A[0] + A[1]\n b = B[0]\n if a < b:\n cost -= A.popleft()\n else:\n cost -= B.popleft()\n\n if cost < 0:\n break\n count += 1\n \n print(count)\n\n\nif __name__ == '__main__':\n main()\n", "import numpy as np\ndef main():\n N, M, K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n \n ia = 0\n ib = 0\n cost = 0\n while True:\n if ia < len(A) and ib < len(B):\n if A[ia] < B[ia]:\n if cost + A[ia] > K:\n break\n ia += 1\n cost += A[ia]\n else:\n if cost + B[ib] > K:\n break\n ib += 1\n cost += B[ib]\n elif ia < len(A):\n if cost + A[ia] > K:\n break\n ia += 1\n cost += A[ia]\n elif ib < len(B):\n if cost + B[ib] > K:\n break\n ib += 1\n cost += B[ib]\n else:\n break\n \n count = ia + ib\n print(count)\n\n\nif __name__ == '__main__':\n main()\n", "from bisect import bisect_right\nimport numpy as np\ndef main():\n N, M, K = map(int, input().split())\n A = np.array([0] + list(map(int, input().split())), dtype=np.int64)\n B = np.array([0] + list(map(int, input().split())), dtype=np.int64)\n\n As = np.cumsum(A)\n Bs = np.cumsum(B)\n\n count = 0\n\n for i, a in enumerate(As):\n if a > K:\n break\n j = bisect_right(Bs, K-a)\n \n count = max(count, (i+j-1))\n\n print(count)\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s709693006', 's876767327', 's536148082']
[59760.0, 58420.0, 53996.0]
[320.0, 254.0, 656.0]
[713, 897, 551]
p02623
u477837488
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n, m, k = map(int, input().split())\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_, b_ = [0], [0]\n\nfor i in range(n):\n a_.append(a_[i] + a[i])\nfor j in range(m):\n b_.append(b_[j] + b[j])\n\nans = 0\nfor i in range(n+1):\n \n idx2 = m\n while a_[i] + b_[idx2] > k:\n idx2 -= 1\n \n ans = max(ans, i + idx2)\nprint(ans)', 'n, m, k = map(int, input().split())\n\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_, b_ = [0], [0]\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\nj = m\n\nfor i in range(n+1):\n \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']
['s163502021', 's535705159']
[47580.0, 47516.0]
[2207.0, 280.0]
[365, 377]
p02623
u480168496
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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], B = [0]\nfor i in range(n):\n A.append(A[i] + a[i])\nfor i in range(m):\n B.append(B[i] + b[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if A[i] > k:\n break\n while B[j] > k - A[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)', 'n, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nA, B = [0], [0]\nfor i in range(n):\n A.append(A[i] + a[i])\nfor i in range(m):\n B.append(B[i] + b[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if A[i] > k:\n break\n while B[j] > k - A[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s575853523', 's695368672']
[9140.0, 47504.0]
[28.0, 295.0]
[359, 359]
p02623
u484052148
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['from itertools import accumulate\nfrom bisect import bisect_right\nN, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = list(accumulate(A))\nSB = list(accumulate(B))\n\nans = 0\nfor i in range(len(SA)):\n if tmp := K-SA[i] < 0:\n break\n ans = max(ans, bisect_right(SB, tmp))\nprint(ans)', 'from itertools import accumulate\nfrom bisect import bisect_right\nN, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = list(accumulate(A))\nSB = list(accumulate(B))\n\nans = 0\nfor i in range(len(SA)):\n ans = max(ans, bisect_right(SB, K-SA[i]))\nprint(ans)', 'from itertools import accumulate\nfrom bisect import bisect_right\nN, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = list(accumulate(A))\nSB = list(accumulate(B))\n\nans = 0\nfor i in range(len(SA)):\n if tmp := K-SA[i] < 0:\n break\n ans = max(ans, bisect_right(SB, tmp)+i)\nprint(ans)', 'from itertools import accumulate\nfrom bisect import bisect_right\nN, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = list(accumulate(A))\nSB = list(accumulate(B))\n\nans = 0\nfor n in range(len(SA)):\n tmp = K-SA[n]\n if tmp < 0:\n break\n m = bisect_right(SB, tmp)\n ans = max(ans, n+m)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s033956550', 's086556840', 's227327442', 's752543448']
[49344.0, 49308.0, 49168.0, 49140.0]
[251.0, 244.0, 256.0, 265.0]
[356, 319, 358, 375]
p02623
u485319545
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nimport bisect\n\nra=[0]+list(np.cumsum(a))\nrb=[0]+list(np.cumsum(b))\n\nans=0\nfor i in range(n+1): \n capa = k - ra[i]\n if ra[i]>0:\n break\n j=bisect.bisect_right(rb,capa)\n\n\n ans=max(ans,i-1+j)\n \nprint(ans) ', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nimport numpy as np\nimport bisect\n\nra=[0]+list(np.cumsum(a))\nrb=[0]+list(np.cumsum(b))\n\nans=0\nfor i in range(n+1): \n capa = k - ra[i]\n if ra[i]>0:\n break\n j=bisect.bisect_right(rb,capa)\n\n\n ans=max(ans,i-1+j)\n \nprint(ans) \n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nimport numpy as np\nimport bisect\n\nra=[0]+list(np.cumsum(a))\nrb=[0]+list(np.cumsum(b))\n\nans=0\nfor i in range(n+1): \n capa = k - ra[i]\n if ra[i]>k:\n break\n j=bisect.bisect_right(rb,capa)\n\n\n ans=max(ans,i-1+j)\n \nprint(ans) \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s386858979', 's524666932', 's460990952']
[59972.0, 59824.0, 60200.0]
[266.0, 256.0, 504.0]
[354, 355, 355]
p02623
u485819963
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\nB = list(map(int, input().split()))\n\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\n\nans, j = 0, M\n\n\n\n\n\nfor i in range(N+1):\n if a[i] > K:\n break\n # print(a[i])\n while b[j] > K -a[i]:\n \n j -= 1\n print(b[j])\n \n ans = max(ans, i + j)\nprint(ans)\n\n\n', '\nN, M, K = map(int,input().split())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\n\nans, j = 0, M\n\n\n\n\n\nfor i in range(N+1):\n if a[i] > K:\n break\n # print(a[i])\n while b[j] > K -a[i]:\n \n j -= 1\n # print(b[j])\n \n ans = max(ans, i + j)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s584410778', 's531224612']
[49208.0, 47308.0]
[349.0, 303.0]
[1932, 1932]
p02623
u490489966
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['#C\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\ni = 0\nj = 0\nfor _ in range(n+m)\n # print(i,j,k)\n if n <= i:#\n k -= b[j]\n j += 1\n if k < 0:\n break\n ans += 1\n if k == 0:\n break\n continue\n elif n <= j:\n k -= a[i]\n i += 1\n if k < 0:\n break\n ans += 1\n if k == 0:\n break\n continue\n if a[i] < b[j]:\n k -= a[i]\n i += 1\n else:\n k -= b[j]\n j += 1\n if k < 0:\n break\n ans += 1\n if k == 0:\n break\nprint(ans)', '#C\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA = [0]\nB = [0]\n\nfor i in range(n):\n A.append(A[i] + a[i])\nfor i in range(m):\n B.append(B[i] + b[i])\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)', '#C\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA = [0]\nB = [0]\n\nfor i in range(n):\n A.append(A[i] + a[i])\nfor i in range(m):\n B.append(B[i] + b[i])\nans = 0\nj = m\n\nfor i in range(n + 1):\n if A[i] > k:\n break\n \n while A[i] + B[j] > k:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s063233599', 's363588982', 's878235582']
[9036.0, 47684.0, 47324.0]
[24.0, 184.0, 284.0]
[659, 480, 531]
p02623
u497805118
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['\nimport bisect\nimport numpy\n\nn, m, k = map(int, input().split(" "))\na = list(map(int, input().split(" ")))\nb = list(map(int, input().split(" ")))\n\ncost_a = numpy.insert(numpy.cumsum(a), 0, 0)\ncost_b = numpy.insert(numpy.cumsum(b), 0, 0)\n\nans = 0\nj = len(cost_b)\nfor i in range(len(cost_a)):\n for j in range( j, 0, -1):\n if cost_a[i] + cost_b[j] <= k:\n ans = i + j if ans < i + j else ans\n break\nprint(ans)', '\nimport bisect\nimport numpy\n\nn, m, k = map(int, input().split(" "))\na = list(map(int, input().split(" ")))\nb = list(map(int, input().split(" ")))\n\ncost_a = numpy.insert(numpy.cumsum(a), 0, 0)\ncost_b = numpy.insert(numpy.cumsum(b), 0, 0)\n\nans = 0\nj = len(cost_b) -1\nfor i in range(len(cost_a)):\n for j in range( j, 0, -1):\n if cost_a[i] + cost_b[j] <= k:\n ans = i + j if ans < i + j else ans\n break\nprint(ans)\n[root@local', '\nimport bisect\nimport numpy\n\nn, m, k = map(int, input().split(" "))\na = list(map(int, input().split(" ")))\nb = list(map(int, input().split(" ")))\n\ncost_a = numpy.insert(numpy.cumsum(a), 0, 0)\ncost_b = numpy.insert(numpy.cumsum(b), 0, 0)\n\nans = 0\nj = len(cost_b) -1\nfor i in range(len(cost_a)):\n for j in range(j, -1, -1):\n if cost_a[i] + cost_b[j] <= k:\n ans = i + j if ans < i + j else ans\n break\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s456403324', 's508141027', 's204950520']
[58476.0, 8884.0, 58388.0]
[229.0, 26.0, 539.0]
[439, 454, 442]
p02623
u497883442
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n\u3000a.append(a[i] + A[i])\nfor i in range(M):\n\u3000b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n\u3000if a[i] > K:\n\u3000\u3000break\n\u3000while b[j] > K - a[i]:\n\u3000\u3000j -= 1\n\u3000ans = max(ans, i + j)\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\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']
['s918519865', 's564032092']
[8908.0, 47444.0]
[26.0, 305.0]
[353, 344]
p02623
u498658826
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['/usr/bin/env python3\nimport sys\n\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\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)', '#!/usr/bin/env python3\nimport sys\n\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\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', '#!/usr/bin/env python3\nimport sys\n\ndef solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):\n weightA = 0\n tmp_A = N\n for idx, a in enumerate(A):\n if weightA + a > K:\n tmp_A = idx\n break\n else:\n weightA += a\n max_count = current_count = tmp_A\n len_A = tmp_A\n\n weightB = 0\n terminated = False\n for b in B:\n if terminated == True and weightA + weightB > K:\n break\n\n if len_A==0 and weightA + weightB + b > K:\n break\n\n if weightA + weightB + b <= K:\n weightB += b\n current_count += 1\n\n elif terminated==False:\n while weightA + weightB + b > K:\n if len_A>0:\n weightA -= A[len_A-1]\n len_A -= 1\n current_count -= 1\n else:\n terminated=True\n\n if weightA + weightB + b <= K:\n weightB += b\n current_count += 1\n if current_count < max_count:\n break\n max_count = max(max_count, current_count)\n\n print(max_count)\n return\n\n\ndef solve_old(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):\n weightA = 0\n tmp_A = N\n for idx, a in enumerate(A):\n if weightA + a > K:\n tmp_A = idx\n break\n else:\n weightA += a\n max_count = current_count = tmp_A\n len_A = tmp_A\n\n weightB = 0\n terminated = False\n for b in B:\n if terminated == True and weightA + weightB > K:\n break\n\n if len_A==0 and weightA + weightB + b > K:\n break\n\n if weightA + weightB + b <= K:\n weightB += b\n current_count += 1\n\n elif terminated==False:\n while weightA + weightB + b > K:\n if len_A>0:\n weightA -= A[len_A-1]\n len_A -= 1\n current_count -= 1\n else:\n terminated=True\n\n if weightA + weightB + b <= K:\n weightB += b\n current_count += 1\n max_count = max(max_count, current_count)\n\n print(max_count)\n return\n', '#!/usr/bin/env python3\nimport sys\n\n\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans = 0\nj = N\n\nfor i in range(M+1):\n if b[i] > K:\n break\n while a[j] > K - b[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s739433933', 's958070816', 's971171070', 's887558541']
[9004.0, 47176.0, 9236.0, 47296.0]
[27.0, 269.0, 25.0, 307.0]
[393, 386, 2213, 398]
p02623
u500673386
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ni=0;j=0;ans=0\nwhile k>0:\n if i<n and j<m:\n if a[i]<=b[j]:\n k-=a[i]\n ans+=1\n i+=1\n continue\n else:\n k-=b[j]\n ans+=1\n j+=1\n continue\n elif i==n and j<m:\n k-=b[j]\n ans+=1\n j+=1\n continue\n elif i<n and j==m:\n k-=a[i]\n ans+=1\n i+=1\n continue\nprint(ans-1 if (i==0 and j==1)or(i==1 and j==0)else ans)', 'n,m,k=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\na=[0];b=[0];ans=0;j=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 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()))\na=[0];b=[0];ans=0;j=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\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()))\na=[0];b=[0];ans=0;j=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 while b[j]>k-a[i]:\n j-=1\n ans=max(ans,i+j)\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s090467850', 's428666193', 's961723782', 's620046845']
[40408.0, 47480.0, 47328.0, 47496.0]
[233.0, 235.0, 209.0, 288.0]
[641, 318, 310, 322]
p02623
u505391462
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.
['N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na,b=[0],[0]\nfor i in range(N):\n\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\nans,j=0,M\nfor i in range(N + 1): \n\tif a[i]>K:\n \tbreak\n\twhile b[j] > K - a[i]:\n \t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)\n\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\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\nans=0\nj=M\nfor i in range(N + 1): \n\tif a[i]>K:\n \tbreak\n\twhile b[j] > K - a[i]:\n \tj -= 1\n\tans = max(ans, i + j)\nprint(ans)\n', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na,b=[0],[0]\nfor i in range(N):\n\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\nans,j=0,M\nfor i in range(N + 1): \n\tif a[i]>K:\n \tbreak\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()))\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])\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\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s342106787', 's406821282', 's843103144', 's567578654']
[8900.0, 9060.0, 8968.0, 47312.0]
[26.0, 25.0, 24.0, 309.0]
[333, 331, 327, 334]
p02623
u511449169
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nprint(b[j])\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)', 'n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s161769167', 's841699513']
[47448.0, 47368.0]
[297.0, 315.0]
[374, 362]
p02623
u512099209
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\ndp = [[0] * (M + 1) for _ in range(N + 1)]\n \nres = 0\n\nfor i in range(1, N + 1):\n dp[i][0] = dp[i - 1][0] + A[-i]\n if dp[i][0] <= K:\n res = max(res, i)\n else:\n break\n\nfor j in range(1, M + 1):\n dp[0][j] = dp[0][j - 1] + B[-j]\n if dp[0][j] <= K:\n res = max(res, j)\n else:\n break\n\nfor i in range(1, N + 1):\n for j in range(1, M + 1):\n dp[i][j] = min(dp[i - 1][j] + A[-i], dp[i][j - 1] + B[-j])\n if dp[i][j] <= K:\n res = max(res, i + j)\n else:\n break\n\nprint(res)', 'N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ndp = [[0] * (M + 1) for _ in range(N + 1)]\n\nfor i in range(1, N + 1):\n dp[i][0] = dp[i - 1][0] + A[-i]\n\nfor j in range(1, M + 1):\n dp[0][j] = dp[0][j - 1] + B[-j]\n \nres = 0\n\nfor i in range(1, N + 1):\n for j in range(1, M + 1):\n dp[i][j] = min(dp[i - 1][j] + A[-i], dp[i][j - 1] + B[-j])\n if dp[i][j] <= K:\n res = max(res, i + j)\n\nprint(res)', 'N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nAs = [0] * (N + 1)\nBs = [0] * (M + 1)\n\nfor i in range(1, N + 1):\n As[i] = As[i - 1] + A[i - 1]\n if As[i] > K:\n i -= 1\n break\n\nfor j in range(1, M + 1):\n Bs[j] = Bs[j - 1] + B[j - 1]\n if Bs[j] > K:\n j -= 1\n break\n\nif i < j:\n As, Bs = Bs, As\n i, j = j, i\n\nj = 0\nn = i\nwhile i:\n while j + 1 < len(Bs) and As[i] + Bs[j + 1] <= K:\n j += 1\n n = max(n, i + j)\n #print(As, Bs, i, j, n)\n i -= 1\n\nprint(n)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s067742384', 's156695990', 's711754143']
[2642076.0, 2707984.0, 40776.0]
[2285.0, 2298.0, 399.0]
[612, 470, 535]
p02623
u514395957
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 \t\tj -= 1\n \t\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 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']
['s699503898', 's187595556']
[8828.0, 47512.0]
[23.0, 277.0]
[342, 344]
p02623
u516554284
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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\nc=[0]\nd=[0]\n\nfor i in range(n):\n c.append(c[-1]+a[i])\n \nfor j in range(m):\n d.append(d[-1]+b[j])\n\nans=0\nfor x in range(n):\n l=c[x+1]-c[x]\n B=0\n if l<=k:\n h=k-l\n mi=0\n ma=m+1\n while ma-mi>1:\n mid=(mi+ma)//2\n if d[mid]<=h:\n mi=mid\n elif d[mid]<h:\n mi=mid\n B=mi\n \n ans=max(ans,x+1+B)\n \nprint(ans)\n', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nc=[0]\nd=[0]\n\nfor i in range(n):\n c.append(c[-1]+a[i])\n \nfor j in range(m):\n d.append(d[-1]+b[j])\n\nans=0\nfor x in range(n):\n l=c[x+1]-c[x]\n B=0\n if l<=k:\n h=k-l\n mi=0\n ma=m+1\n while ma-mi>1:\n mid=(mi+ma)//2\n if d[mid]<=h:\n mi=mid\n elif d[mid]>h:\n ma=mid\n B=mi\n \n ans=max(ans,x+1+B)\n \nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nc=[0]\nd=[0]\n\nfor i in range(n):\n c.append(c[-1]+a[i])\n \nfor j in range(m):\n d.append(d[-1]+b[j])\n\nans=0\nfor x in range(n):\n l=c[x+1]-c[x]\n B=0\n if l<=k:\n h=k-l\n mi=0\n ma=m+1\n while ma-mi>1:\n mid=(mi+ma)//2\n if d[mid]<=h:\n mi=mid\n elif d[mid]<h:\n ma=mid\n B=mi\n \n ans=max(ans,x+1+B)\n \nprint(ans)', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\n\nfor x in range(n):\n sum1=0\n ans1=0\n \n sum1=sum(a[0:x])\n if sum1>k:\n break\n else:\n \tans1+=x+1\n for y in range(m):\n \n \n sum1+=b[y]\n if sum1>k:\n break\n else:\n ans1+=1\n if ans1>ans:\n ans=ans1\n \nprint(ans)\n ', 'n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\nc=[0]\nd=[0]\n\nfor i in range(n):\n c.append(c[-1]+a[i])\n \nfor j in range(m):\n d.append(d[-1]+b[j])\n\nans=0\nfor x in range(n+1):\n l=c[x]\n B=0\n if l<=k:\n h=k-l\n mi=0\n ma=m+1\n while ma-mi>1:\n mid=(mi+ma)//2\n if d[mid]<=h:\n mi=mid\n elif d[mid]>h:\n ma=mid\n B=mi\n \n ans=max(ans,x+B)\n \n \n \nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s033232513', 's134064026', 's508381723', 's825900808', 's179176294']
[48832.0, 48660.0, 48700.0, 40488.0, 48700.0]
[2207.0, 1194.0, 2207.0, 2206.0, 1115.0]
[453, 452, 452, 366, 456]
p02623
u516927307
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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[1])\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 \n ans = max(ans, i+j)\n \nprint(ans)', 'N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K-a[i]:\n j -= 1\n \n ans = max(ans, i+j)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s868809880', 's931894960']
[47504.0, 47548.0]
[290.0, 296.0]
[364, 364]
p02623
u517388115
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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()))\nta=0\ntb=0\nans=0\nfor i in range(n+1):\n ta += a[i]\n if i=0:\n ta=0\n if ta>k:\n break\n for j in range(m):\n tb=sum(b[:j+1])\n ans=max(ans,i+j)\n if tb + ta >k:\n break\n ans=max(ans,i+j+1)\nprint(ans)\n', 'n, m, k =map(int, input().split())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nta=sum(a)\na.append(0)\ntb=0\nans=0\nj=0\nfor i in range(n+1):\n ta -= a[n-i]\n if ta>k:\n continue\n while tb + ta<=k:\n\n if j ==m:\n ans=max(ans,n-i+j)\n break\n ans=max(ans,n-i+j)\n tb += b[j]\n j +=1\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s904434528', 's047885182']
[8980.0, 40384.0]
[26.0, 285.0]
[358, 370]
p02623
u518958552
2,000
1,048,576
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this 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 aaa():\n n,m,k = map(int,input().split())\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n c = []\n for i,j in zip(a,b):\n if i <= j:\n c.append(i)\n c.append(j)\n else:\n c.append(j)\n c.append(i)\n d = 0\n e = 0\n for i in c:\n if i+e < k:\n e += i\n d += 1\n else:\n return d\n return n + m\naaa()', 'def aaa():\n n,m,k = map(int,input().split())\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n c = []\n for i,j in zip(a,b):\n if i <= j:\n c.append(i)\n c.append(j)\n else:\n c.append(j)\n c.append(i)\n \n a1 = a\n b1 = b\n a1[0:n+1] = []\n b1[0:m+1] = []\n c = c + a1 + b1\n d = 0\n e = 0\n for i in c:\n if i+e < k:\n e += i\n d += 1\n else:\n return d\n return n + m\naaa()', 'def aaa():\n n,m,k = map(int,input().split())\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n if n >= m:\n for _ in range(m-n):\n a.append(10**9+1)\n else:\n for _ in range(n-m):\n b.append(10**9+1)\n c = []\n for i,j in zip(a,b):\n if i <= j:\n c.append(i)\n c.append(j)\n else:\n c.append(j)\n c.append(i)\n d = 0\n e = 0\n for i in c:\n if i+e < k:\n e += i\n d += 1\n else:\n return d\n return n + m\naaa()', 'def aaa():\n n,m,k = map(int,input().split())\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n c = []\n for i,j in zip(a,b):\n c.append(i)\n c.append(j)\n d = 0\n e = 0\n for i in c:\n if i+e < k:\n e += i\n d += 1\n else:\n return d\n return n + m\naaa()', 'def aaa():\n n,m,k = map(int,input().split())\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n c = []\n for i,j in zip(a,b):\n c.append(i)\n c.append(j)\n c = sorted(c)\n d = 0\n e = 0\n for i in c:\n if i+e < k:\n e += i\n d += 1\n else:\n return d\n return n + m\naaa()', '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', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s061619384', 's184206454', 's407819281', 's602240273', 's958103788', 's311335032']
[40604.0, 40108.0, 40488.0, 40452.0, 40452.0, 47548.0]
[173.0, 180.0, 171.0, 163.0, 264.0, 292.0]
[442, 531, 585, 353, 371, 364]