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
p02959
u277353449
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N=int(input())\na=input().split()\nb=input().split()\nfor i in range(0,N):\n a[i]=int(a[i])\n b[i]=int(b[i])\na[N]=int(a[N])\nanswer=sum(a)\nfor i in range(0,N):\n c=b[i]-a[i]\n if c<0:\n a[i]=-c\n b[i]=0\n else:\n a[i]=0\n b[i]=c\n d=b[i]-a[i+1]\n if d<0:\n a[i+1]=...
['Wrong Answer', 'Accepted']
['s197264580', 's079474479']
[18624.0, 18624.0]
[171.0, 166.0]
[381, 381]
p02959
u294385082
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = 0\n\nfor i in range(n):\n c += min(a[i],b[i])\n tmp = min(a[i+1],b[i]-min(a[i],b[i]))\n c += tmp\n if tmp == a[i+1]:\n del a[i+1]\n a.insert(i+1,0)\n else:\n del a[i+1]\n a.insert(i+1,a[i+1]+a[i]-b[i])...
['Runtime Error', 'Accepted']
['s405102542', 's247149807']
[18624.0, 18624.0]
[2104.0, 204.0]
[314, 313]
p02959
u296518383
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input()) \n#n=2\na=list(map(int, input().split())) \n#a = [100, 1, 1]\nb=list(map(int, input().split())) \n#b=[1,100]\nans = 0\n\nfor i in range(n):\n if a[i]>=b[i]:\n ans+=b[i]\n a[i]-=b[i]\n b[i]=0\n else:\n ans+=a[i]\n b[i]-=a[i]\n a[i]=0\n if a[i+1]>=b[i...
['Wrong Answer', 'Accepted']
['s776104208', 's217155943']
[18752.0, 18624.0]
[166.0, 167.0]
[628, 639]
p02959
u301302814
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['# coding: utf-8\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n for i in range(N):\n b = int(input())\n tmp = A[i] - b\n if tmp < 0:\n ans += A[i]\n if A[i + 1] < -tmp:\n ans += A[i + 1]\n A[i + 1] = 0\n ...
['Runtime Error', 'Accepted']
['s780477801', 's693130709']
[20064.0, 24276.0]
[55.0, 100.0]
[468, 501]
p02959
u308523782
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ncnt = 0\nfor i in range(n-1):\n if a[i] >= b[i]:\n cnt += b[i]\n else:\n cnt += a[i]\n b[i] -= a[i]\n cnt += min(b[i],a[i+1])\n a[i+1] -= min(b[i],a[i+1])\ncnt += min(a[-1],b[-1])\nprint(...
['Wrong Answer', 'Accepted']
['s394519751', 's221852673']
[24028.0, 24316.0]
[172.0, 168.0]
[309, 283]
p02959
u309039873
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nanswer = 0\n\nfor i in range(N+1):\n if i == 0:\n if A[i] < B[i]:\n answer += A[i]\n B[i] -= A[i]\n A[i] = 0\n else:\n answer += B[i]\n A[i] -= B[i]\n ...
['Wrong Answer', 'Accepted']
['s857534465', 's123057021']
[18752.0, 18476.0]
[172.0, 161.0]
[929, 929]
p02959
u309120194
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\n\n\n\nfor i in range(N):\n if A[i] >= B[i]: A[i] -= B[i]\n else:\n # A[i] < B[i]\n A[i] = 0\n A[i+1] -= B[i] - A[i]\n\nprint(sum(A))', 'N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, in...
['Wrong Answer', 'Accepted']
['s104525719', 's300201245']
[23904.0, 24128.0]
[103.0, 127.0]
[387, 851]
p02959
u314089899
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['#135c\nN = str(input())\nlist_A = list(map(int, input().split()))\nlist_B = list(map(int, input().split()))\n\n#print("#################################################")\n\nans = 0\nremaining_power = 0\n\nif N>1:\n for i in range(N-1,-1,-1):\n \n\n if remaining_power>list_A[i+1]:\n \n ...
['Runtime Error', 'Accepted']
['s664858703', 's147244565']
[19004.0, 18752.0]
[67.0, 133.0]
[1039, 1043]
p02959
u318740143
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\ncount =0\nX = A[-1]\nfor i in range(N):\n if A[i] >= B[i] and A[i] >= 0:\n count += B[i]\n elif A[i] < B[i] and A[i] >= 0:\n A[i+1] = A[i+1] - (B[i] - A[i])\n count += A[i]\nif A[-1] >= 0:\n count += X - A[N+1]\nels...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s061438307', 's338722871', 's534613663', 's624845208']
[18624.0, 18476.0, 19004.0, 18752.0]
[139.0, 153.0, 189.0, 174.0]
[333, 494, 528, 505]
p02959
u329143273
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ncnt=0\nfor i in range(n):\n if a[i]==b[i]:\n cnt+=a[i]\n elif a[i]<b[i]:\n cnt+=a[i]\n a[i]=0\n x=b[i]-a[i]\n if x>=a[i+1]:\n cnt+=a[i+1]\n a[i+1]=0\n else:\n cnt+=(a[i+1]-x)\n a[i+1]=a[i+1]-x\n...
['Wrong Answer', 'Accepted']
['s711416640', 's589365655']
[18752.0, 18476.0]
[173.0, 156.0]
[344, 324]
p02959
u329407311
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\n\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\ncnt = 0\n\nai = A[0]\nai2 = A[1]\n\nfor i in range(N):\n\n bi = B[i]\n \n if ai <= bi:\n cnt += ai\n \n if ai2 <= (bi - ai):\n cnt += ai2\n ai = max(0, ai2-(bi - ai))\n ai2 = A[i+2]\n else:\n ...
['Runtime Error', 'Accepted']
['s138682512', 's228598809']
[18624.0, 18624.0]
[149.0, 148.0]
[447, 473]
p02959
u333404917
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nresult = 0\nbeated = min(a[0],b[0])\nresult += beated\n\nfor i in range(1, n):\n beated = min(a[i],b[i]-beated)\n result += beated\nprint(result)', 'n = int(input())\na = [int(x) for x in input().split()]\nb = [int...
['Wrong Answer', 'Accepted']
['s400698127', 's003186044']
[18624.0, 18468.0]
[123.0, 174.0]
[238, 265]
p02959
u340098288
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['#coding: UTF-8\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nAns = 0\n\nfor num in range(N):\n Ans += min(A[num], B[num])\n if A[num] => B[num]:\n pass\n else: # A[num] < B[num]\n B[num] -= A[num]\n Ans += min(A[num+1], B[num])\n ...
['Runtime Error', 'Accepted']
['s726748699', 's581075012']
[2940.0, 18624.0]
[17.0, 200.0]
[406, 406]
p02959
u343292604
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nA.reverse()\nB.reverse()\nans = 0\nt = A[0]\nfor a, b in zip(A[1:], B):\n t += a\n print(ans, t)\n m = min(t, b)\n ans += m\n t = t - m if t - a <= b else a\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int,...
['Wrong Answer', 'Accepted']
['s796785570', 's190393890']
[18476.0, 18624.0]
[258.0, 126.0]
[264, 246]
p02959
u344276999
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nB.append(0)\n\nans = 0\nfor i in range(N+1):\n taosukazu1 = min(A[i],B[i])\n B[i] -= taosukazu1\n A[i] -= taosukazu1\n ans += taosukazu1\n print(A)\n print(B)\n if B[i] > 0:\n taosukazu2 = min(A[i+1],B[i])\n B...
['Runtime Error', 'Accepted']
['s057484473', 's379512555']
[149212.0, 25448.0]
[1639.0, 187.0]
[376, 356]
p02959
u350093546
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input()split()))\nb=list(map(int,input()split()))\nx=sum(a)\nfor i in range(n):\n if a[i]>=b[i]:\n a[i]-=b[i]\n else:\n a[i]=0\n a[i+1]-=b[i]-a[i]\nprint(x-sum(a))', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx=sum(b)\nfor i in range(...
['Runtime Error', 'Accepted']
['s221617726', 's754396574']
[2940.0, 18476.0]
[17.0, 236.0]
[195, 208]
p02959
u357230322
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nm=0\nt=len(B)\nfor i in range(t)\nif a[i]>=b[i]:\n m+=b[i]\n if a[i]-b[i]>=b[i+1]:\n m+=b[i+1]\n b[i+1]=0\n else:\n m+=a[i]-b[i]\n b[i+1]-=a[i]-b[i]\nelse:\n m+=a[i]\n ', 'n=int(input())\na=list(map(int,input().split(...
['Runtime Error', 'Accepted']
['s645512102', 's671721674']
[2940.0, 18624.0]
[17.0, 147.0]
[253, 301]
p02959
u360515075
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nS = sum(A)\nfor i in range(N-1,-1,-1):\n if B[i] > 0:\n if A[i+1] < B[i]:\n A[i+1] = 0\n B[i] = B[i] - A[i+1]\n else:\n A[i+1] = A[i+1] - B[i]\n B[i] = 0\n if B[i] > 0:\n if A[i] < B[i]:\n ...
['Wrong Answer', 'Accepted']
['s985548915', 's223852337']
[19004.0, 19004.0]
[160.0, 162.0]
[408, 408]
p02959
u361381049
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['cnt = 0\nans = 0\n\nfor i in range(n):\n cnt = b[i] - a[i]\n if cnt > 0:\n ans += a[i]\n if a[i+1] >= cnt:\n ans += cnt\n a[i+1] -= cnt\n else:\n ans += a[i+1]\n a[i+1] =0\n \n \n else:\n ans += b[i]\n\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\nb =...
['Runtime Error', 'Accepted']
['s188902187', 's027359222']
[3060.0, 18476.0]
[17.0, 135.0]
[238, 327]
p02959
u365993347
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['def getInt(): return int(input())\n\ndef getIntList(): return [int(x) for x in input().split()]\n\nN = getInt()\nA = getIntList()\nB = getIntList()\nsum = 0\nsum += min(A[0],B[0])\nsum += min(A[1],B[0]-min(A[0],B[0]))\nfor i in range(N-1):\n sum += min(A[i+1]-min(A[1],B[0]-min(A[0],B[0])),B[i+1])\n sum += min(A...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s109824466', 's723449554', 's952522738', 's336402741']
[19776.0, 19648.0, 19648.0, 18624.0]
[265.0, 248.0, 198.0, 204.0]
[349, 351, 350, 339]
p02959
u368016155
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = [int(_) for _ in input().split()]\nB = [int(_) for _ in input().split()]\n\nmonster = 0\nfor i in range(N):\n if A[i] >= B[i]:\n A[i]=A[i]-B[i]\n monster += B[i]\n else:\n monster += A[i]\n A[i]=0\n if A[i+1]>(B[i]-A[i]):\n monster += (B[i]-A[i...
['Wrong Answer', 'Accepted']
['s977968608', 's385333057']
[19776.0, 18624.0]
[165.0, 150.0]
[428, 431]
p02959
u371132735
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\nfor i in range(N):\n ans += min(B[i],A[i]+A[i+1])\n if B[i]>A[i]:\n A[i+1] = max(0,B[i]-A[i])\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0...
['Wrong Answer', 'Accepted']
['s743760180', 's437646104']
[18624.0, 19156.0]
[154.0, 199.0]
[209, 218]
p02959
u372102441
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['\nN = int(input())\nA = input().split()\nB = input().split()\nfor i in range(N+1):\n A[i] = int(A[i])\nfor i in range(N):\n B[i] = int(B[i])\n\nAns = 0\nyo = 0\nchinpo = True\n\nfor i in range(N):\n if chinpo:\n Ans += min(A[i],B[i])\n if B[i] > A[i]:\n yo = B[i] - A[i]\n ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s116480838', 's289726219', 's362091023', 's658930757', 's732107901', 's760534663', 's781839250', 's882713436', 's903972690', 's960670243', 's034715209']
[18624.0, 3064.0, 20748.0, 18624.0, 20668.0, 19412.0, 18624.0, 18624.0, 18624.0, 20748.0, 20748.0]
[151.0, 17.0, 157.0, 178.0, 157.0, 139.0, 145.0, 176.0, 155.0, 153.0, 155.0]
[632, 913, 441, 691, 952, 390, 497, 432, 795, 443, 441]
p02959
u372144784
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\np = input()\nlist1 = list(map(int,p.split()))\n\nlist2 = []\nfor i in range(1,N + 1):\n list2.append(i)\n\nif list1 == list2:\n print("YES")\n exit()\nfor i in range(0,N):\n if list1[i] != i+1:\n if i+1 == list1[list1[i]-1]:\n list1[list1[i]-1] = list1[i]\n l...
['Runtime Error', 'Accepted']
['s192405729', 's664384611']
[15168.0, 20800.0]
[55.0, 146.0]
[458, 541]
p02959
u375500286
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ns=0\ny=0\nfor i in range(n+1):\n v=max(0,a[i]-y)\n if v<=b[i]:\n s+=a[i]\n y=b[i]-v\n elif v>b[i]:\n s+=b[i]+y\n y=0\nprint(s)', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,in...
['Runtime Error', 'Accepted']
['s529024247', 's007364844']
[18624.0, 18624.0]
[129.0, 125.0]
[234, 245]
p02959
u377989038
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import sys\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n\n tmp = 0\n ans = 0\n for i in range(n):\n mon = max(0, a[i] - tmp)\n\n if b[i] <= mon:\n ans += b[i] + tmp\n tmp...
['Wrong Answer', 'Accepted']
['s669985713', 's148806336']
[19376.0, 19228.0]
[108.0, 106.0]
[520, 518]
p02959
u390170391
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = 0\nfor i in range(0,n+1):\n if a[i] > b[i]:\n c = c + b[i]\n elif a[i] <= b[i]:\n c = c + a[i]\n b[i] = b[i] - a[i]\n if b[i] < a[i+1]:\n c = c + b[i]\n a[i+1] = a[i+1] - b[i]\n else:\n c = c ...
['Runtime Error', 'Accepted']
['s997869358', 's328453245']
[18476.0, 18624.0]
[169.0, 169.0]
[338, 337]
p02959
u390883247
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\nfor i in range(N):\n b = B[i]\n a = A[i]\n a2 = A[i+1]\n\n if a <= b:\n ans += a\n A[i] = 0\n b -= a\n else:\n ans += b\n A[i] -= b\n b = 0\n\n if b > 0:\n ...
['Wrong Answer', 'Accepted']
['s246662323', 's366241028']
[18624.0, 18624.0]
[168.0, 163.0]
[479, 469]
p02959
u390901183
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ns1 = sum(a)\nfor i in range(n + 1):\n if i == 0:\n if a[i] < b[i]:\n b[i] -= a[i]\n a[i] = 0\n else:\n a[i] -= b[i]\n b[i] = 0\n elif i == n:\n if a[i] <...
['Runtime Error', 'Accepted']
['s937691477', 's655141348']
[18752.0, 18476.0]
[152.0, 152.0]
[651, 655]
p02959
u392938961
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = 0\nfor i in range(n):\n if a[i] < b[i]:\n if a[i]+a[i+1] <= b[i]:\n c += a[i]+a[i+1]\n a[i+1] = 0\n else:\n c += a[i]\n a[i+1] -= (b[i]-a[i])\n elif a[i] >= b...
['Wrong Answer', 'Accepted']
['s352367203', 's544359677']
[18476.0, 18476.0]
[141.0, 141.0]
[343, 343]
p02959
u393512980
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import sys\nsys.setrecursionlimit(100000000)\ndef input():\n return sys.stdin.readline()[:-1]\nfrom bisect import *\nfrom collections import *\nfrom heapq import *\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n if a[i] >= b[i]:\n ...
['Wrong Answer', 'Accepted']
['s330242678', 's512640721']
[18852.0, 18852.0]
[200.0, 172.0]
[437, 539]
p02959
u394731058
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
["import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 0\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n t = 0\n for i in range(n):\n for j in range(i, i+2):\n if a[j] >= b[i]:\n a[j] -= b[i]\n ...
['Wrong Answer', 'Accepted']
['s592251472', 's131193129']
[24532.0, 24420.0]
[123.0, 123.0]
[492, 482]
p02959
u395202850
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na, b = [list(map(int, input().split())) for _ in range(2)]\nbSum = 0\nfor i in range(n):\n if a[i] >= b[i]:\n bSum += b[i]\n a[i] -= b[i]\n b[i] = 0\n elif a[i] + a[i + 1] >= b[i]:\n bSum += b[i]\n a[i] = 0\n a[i + 1] -= b[i] - a[i]\n elif a[i] + a[...
['Wrong Answer', 'Accepted']
['s023751769', 's511862939']
[18624.0, 19156.0]
[147.0, 143.0]
[388, 347]
p02959
u413165887
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
["n = int(input())\na = list(map(int, input().split(' ')))\nb = list(map(int, input().split(' ')))\n\nresult = 0\nsum_a = sum(a)\nfor i in range(n):\n if a[i] <= b[i]:\n b[i] -= a[i]\n a[i] = 0\n if a[i+1] <= b[i]:\n a[i+1] = 0\n else:\n a[i+1] -= b[i]\n else:\n ...
['Runtime Error', 'Accepted']
['s777263486', 's474771768']
[146660.0, 18624.0]
[1845.0, 147.0]
[375, 255]
p02959
u415905784
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input().split())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\nL = 0\nfor i in range(N):\n l = min(A[i], B[i])\n r = min(A[i + 1], B[i])\n A[i + 1] -= r\n L += l + r\nprint(L)', 'N = int(input())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]...
['Runtime Error', 'Accepted']
['s197817589', 's635907153']
[3060.0, 18468.0]
[19.0, 181.0]
[211, 215]
p02959
u416758623
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\nfor i in range(n):\n print(a,b)\n if b[i] >= sum(a[i:i+2]):\n ans += sum(a[i:i+2])\n a[i+1] = 0\n elif a[i] >= b[i]:\n ans += b[i]\n elif a[i] < b[i]:\n ans += b[i]\n a...
['Runtime Error', 'Accepted']
['s543398792', 's593812659']
[146852.0, 18624.0]
[1873.0, 178.0]
[335, 320]
p02959
u417014669
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['b=[int(i) for i in input().split()]\nsum=np.sum(b)\nfor i in reversed(range(n)):\n k = a[i+1]\n l = a[i]\n m = b[i]\n \n a[i+1] = max(k-m, 0)\n b[i] = max(m-k, 0)\n \n a[i] = max(l-b[i], 0)\n b[i] = max(b[i]-l, 0)\npostsum=np.sum(b)\nprint(sum-postsum)\n ', 'import numpy as np\nn=int(input())\na=[int(i) for i ...
['Runtime Error', 'Accepted']
['s216683337', 's880918088']
[3064.0, 27324.0]
[17.0, 379.0]
[248, 316]
p02959
u417794477
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nAlist = list(map(int, input().split()))\nBlist = list(map(int, input().split()))\nbeforeN = sum(Alist)\nfor i in range(N - 1, -1, -1):\n rest_power = Blist[i] - Alist[i + 1]\n if rest_power > 0:\n Alist[i + 1] = 0\n last_power = Alist[i] - rest_power\n if last_power <= 0:\...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s166377995', 's224408358', 's606297176', 's246348969']
[18624.0, 39680.0, 39824.0, 18624.0]
[136.0, 2209.0, 398.0, 128.0]
[517, 935, 896, 504]
p02959
u431981421
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nans = 0\np = 0\n\nfor index, i in enumerate(A):\n if index > len(B) - 1:\n if p > A[index]:\n ans += A[index]\n else:\n print(p)\n \n break\n\n if A[index] - (B[index] + p) < 0:\n ans += A[index]...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s401536621', 's666043918', 's259893621']
[18624.0, 14400.0, 18624.0]
[142.0, 43.0, 151.0]
[390, 373, 453]
p02959
u434872492
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\ncount = 0\nfor i in range(N):\n judge = A[i] - B[i]\n if judge <= 0:\n count += A[i]\n else:\n count += B[i]\n\n if judge < 0:\n A[i+1] += judge\n if A[i+1] < 0:\n A[i+1] = 0\np...
['Wrong Answer', 'Accepted']
['s162785781', 's052178798']
[18624.0, 18624.0]
[132.0, 147.0]
[314, 397]
p02959
u439312138
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = input()\nA = list((map(int,input().split()))\nB = list(map(int,input().split()))\n\nans = 0\n \nfor i in range(0,N):\n left = A[i] - B[i]\n\tans += min(A[i],B[i])\n \n if left < 0:\n\t\tright = A[i+1] - abs(left)\n \tans += min( A[i+1],abs(left))\n\t\tA[i+1] = right\n\nprint(ans)\n', 'N =...
['Runtime Error', 'Accepted']
['s254924621', 's254629143']
[2940.0, 19116.0]
[17.0, 173.0]
[289, 349]
p02959
u439392790
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\nfor i in range (n):\n if(a[i]>=b[i]):\n ans+=b[i]\n elif(a[i+1]<b[i]-a[i])\n ans+=a[i]+a[i+1]\n a[i+1]=0\n else:\n ans+=b[i]\n a[i+1]-=b[i]-a[i]\nprint(ans)', 'n=int(input())\na=list(...
['Runtime Error', 'Accepted']
['s634481393', 's518170957']
[2940.0, 18476.0]
[17.0, 137.0]
[278, 280]
p02959
u450904670
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nenemy = list(map(int, input().split()))\nbeat = list(map(int, input().split()))\n\ndef hoge(index, index1):\n\tif(index == 0 and index1 == 0):\n\t\treturn min([enemy[0], beat[0]])\n\telif(index1 - index == 1):\n\t\treturn min([enemy[index1], beat[index] - hoge(index, index)])\n\telse:\n\t\treturn mi...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s304306909', 's373735657', 's867030567', 's297761440']
[18476.0, 18376.0, 3064.0, 19156.0]
[366.0, 374.0, 18.0, 208.0]
[443, 451, 509, 327]
p02959
u454093752
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int( input() )\nA_list = list( map( int, input().split() ) )\nB_list = list( map( int, input().split() ) )\nc = max(A_list[0], B_list[0])\nremain_B = max(B_list[0] - A_list[0], 0)\nfor i in range(1, N ):\n c += min(remain_B, A_list[i])\n remain_A = max( A_list[i] - remain_B, 0 )\n c += min(remain_A, B_li...
['Wrong Answer', 'Accepted']
['s477502781', 's870478934']
[19156.0, 19156.0]
[201.0, 198.0]
[400, 401]
p02959
u471212175
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split(" ")))\nB = list(map(int,input().split(" ")))\na = sum(A)\nans = 0\nfor i in range(N):\n tmp = A[i]+A[i+1]-B[i]\n ans = ans + max(0,tmp-A[i+1])\n A[i+1] = min(A[i+1],tmp)\n print(A)\n\nprint(a - ans)', 'N = int(input())\nA = list(map(int,input().split(" "))...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s490875624', 's490917139', 's760908705', 's405362910']
[146828.0, 147012.0, 147476.0, 18624.0]
[1789.0, 1815.0, 1858.0, 166.0]
[249, 249, 457, 394]
p02959
u471499397
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import numpy as np\n\nN = int(input()) + 1\n\nA = input().split()\n\nB = input().split()\n\nenemy = np.zeros(N)\nsaver = np.zeros(N)\n\nbeated = 0\nover = 0\n\nfor i in range(N - 1):\n enemy[i] = int(A[N - i - 2])\n saver[i] = int(B[N - i - 2])\n\nenemy[N - 1] = int(A[N - 1])\n\nfor i in range(N):\n if(enemy...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s509531984', 's898364871', 's828279540']
[28768.0, 28672.0, 28772.0]
[489.0, 488.0, 492.0]
[490, 557, 557]
p02959
u472696272
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nc = [0]*(n+1)\nans = 0\nfor i in range(n):\n if b[i]+c[i] > a[i]:\n if c[i]>=a[i]:\n ans = ans + a[i]\n c[i+1] = b[i]\n else:\n ans = ans = a[i]\n c[i+1] = b[i]+c[i]-a[i]\n else:\n ans = ans + ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s125272472', 's455745003', 's167891324']
[19004.0, 18476.0, 18624.0]
[144.0, 67.0, 143.0]
[385, 316, 309]
p02959
u485252122
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nA=[]\nfor x in input().split():\n A.append(int(x))\n\nB=[]\nfor x in input().split():\n B.append(int(x))\n\nB.append(int(0)) \n\nTOT = sum ( A )\n\nprint ( A )\n\nfor i in range (n) :\n KILL = min ( A[i], B[i] )\n A [i] = A [i] - KILL\n A [i+1] = A[i+1] - min (A[i+1], B[i] - KILL)\...
['Runtime Error', 'Accepted']
['s243098290', 's859800599']
[146716.0, 19372.0]
[1832.0, 192.0]
[350, 317]
p02959
u492026192
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx=0\nfor i in range(n):\n if a[i]<=b[i]:\n x+=a[i]\n if a[i+1]>=b[i]:\n a[i+1]-=b[i]-a[i]\n x+=b[i]-a[i]\n else:\n x+=a[i+1]\n a[i+1]=0\n \n a[i]=0\...
['Wrong Answer', 'Accepted']
['s850537855', 's032581402']
[18624.0, 18752.0]
[158.0, 182.0]
[357, 429]
p02959
u492447501
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\n\n\nS = input()\nS = S.split()\nA = list(map(int, S))\nA_copy = list(map(int, S))\n\nS = input()\nS = S.split()\nB = list(map(int, S))\n\n\nremain = 0\n\nfor i in range(len(B)):\n remain = int(A[i]-B[i])\n if remain <= 0:\n if A[i+1]+remain >= 0:\n A[i+1] = int(A[i+1] + remai...
['Wrong Answer', 'Accepted']
['s878357834', 's525577095']
[22280.0, 22332.0]
[166.0, 169.0]
[446, 428]
p02959
u502967152
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nb.append(0)\ncnt=0\nfor i in range(n):\n if a[i]>=b[i]:\n cnt+=b[i]\n if a[i]<b[i]:\n cnt+=a[i]\n a[i+1]-=b[i]-a[i]\n cnt+=min(b[i]-a[i+1], a[i+1])\n a[i+1]=max(a[i+1], 0)\nprint(str(cnt))\n ', 'n=int(input())\na=l...
['Wrong Answer', 'Accepted']
['s284213206', 's166762192']
[19156.0, 18476.0]
[215.0, 198.0]
[281, 266]
p02959
u503228842
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\ncnt = 0\nfor i in range(N):\n if B[i] <= A[i]:\n cnt += B[i]\n B[i] = 0\n A[i] = 0\n else:\n cnt += min(B[i],A[i]+A[i+1])\n A[i] = 0\n A[i+1] = max(0,A[i+1]-(B[i]-A[i]))\n # p...
['Wrong Answer', 'Accepted']
['s116513255', 's539589525']
[18396.0, 19004.0]
[184.0, 244.0]
[338, 390]
p02959
u504256702
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nans = 0\nfor i in range(len(B)):\n if A[i] - B[i] >= 0:\n A[i] = A[i] - B[i]\n ans += B[i]\n else:\n ans += A[i]\n A[i] = 0\n if A[i+1] - (B[i] - A[i]) >= 0:\n A[i+1] = A[i+1] - (B[i] - A[i])\n ans +...
['Wrong Answer', 'Accepted']
['s035475315', 's824926740']
[19004.0, 18752.0]
[161.0, 180.0]
[395, 395]
p02959
u505893372
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nc = 0\n\nfor i in range(n):\n\tif a[i] >= b[i]:\n\t\tc += b[i]\n\telse:\n\t\tc += a[i]\n\t\tc += min(a[i+1],b[i]-a[i])\n\t\tif a[i+1] >= b[i]-a[i]\n\t\t\ta[i+1] = a[i+1] - (b[i] - a[i])\n\t\telse:\n\t\t\ta[i+1] = 0\nprint(...
['Runtime Error', 'Runtime Error', 'Accepted']
['s172271012', 's386008710', 's076442775']
[3064.0, 2940.0, 18436.0]
[17.0, 17.0, 198.0]
[287, 284, 313]
p02959
u508164527
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nans = []\nA = [int(x) for x in input().split()]\nmoto = sum(A)\nB = [int(x) for x in input().split()]\nfor i in reversed(range(N)):\n if A[i+1] >= B[i]:\n A[i+1] = A[i+1] -B[i]\n else:\n if A[i] >= B[i] -A[i+1]:\n A[i+1] = 0\n A[i] = A[i] + A[i+1] -B[i]\n else:\n A[i+1] = 0...
['Wrong Answer', 'Accepted']
['s621236088', 's664498632']
[18624.0, 19004.0]
[138.0, 144.0]
[339, 356]
p02959
u514118270
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nB.append(0)\nans = 0\nnum = 0\nfor i in range(n+1):\n if num != 0:\n if A[i] - num <= 0:\n num = B[i]\n ans += A[i]\n else:\n A[i] -= num\n num = 0\n if A[i] >= B[i]:\n num = 0\n ans...
['Wrong Answer', 'Accepted']
['s146102776', 's573624804']
[19004.0, 19004.0]
[134.0, 149.0]
[488, 518]
p02959
u516554284
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=0\nfor i in range(n):\n if a[i]>b[i]:\n c+=b[i]\n elif a[i]<=b[i]:\n c+=a[i]\n a[i+1]=b[i]-a[i]\n if a[i+1]<=0:\n a[i+1]=0\nprint(c)', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().spli...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s602393463', 's848282773', 's104569276']
[18624.0, 19156.0, 18624.0]
[134.0, 150.0, 154.0]
[225, 235, 281]
p02959
u525796732
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import sys\nstdin = sys.stdin\n\nns = lambda: stdin.readline().rstrip()\nni = lambda: int(stdin.readline().rstrip())\nnm = lambda: map(int, stdin.readline().split())\nnl = lambda: list(map(int, stdin.readline().split()))\n\nN=int(input())\nA=nl()\nB=nl()\nsumMb=sum(A)\n\nfor i in range(N):\n A[i]-=(min(B[i],A[i]))...
['Wrong Answer', 'Accepted']
['s036787689', 's452867833']
[19228.0, 18624.0]
[196.0, 173.0]
[384, 382]
p02959
u527261492
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nif a[0]-b[0]<0:\n totl=a[0]-b[0]\nfor i in range(n):\n if b[i]+b[i+1]>a[i+1]:\n totl+=a[i+1]-b[i]-b[i+1]\n \nprint(sum(b)+totl)\n \n', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ntotl=...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s048031490', 's100452235', 's305449953', 's432049516', 's478412935', 's490726830', 's533665192', 's546208575', 's619225528', 's742203857', 's821968235', 's994563968', 's743460702']
[18476.0, 19116.0, 19116.0, 18396.0, 19116.0, 18624.0, 18624.0, 18624.0, 18476.0, 18476.0, 19116.0, 18624.0, 18476.0]
[130.0, 121.0, 185.0, 137.0, 200.0, 1226.0, 138.0, 134.0, 118.0, 124.0, 127.0, 139.0, 194.0]
[214, 183, 187, 304, 193, 183, 301, 195, 204, 204, 229, 191, 240]
p02959
u529012223
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nc = A[0]\nd = 0\nfor i in range(N):\n d += max(0, c - B[i])\n c = max(0, A[i+1] + min(0, c - B[i]))\n \nprint(sum(A) - (d + c))', 'N = int(input())\nA = list(map(int, input().split()))\nB = list(map(...
['Runtime Error', 'Accepted']
['s065136190', 's077597374']
[6004.0, 19116.0]
[24.0, 159.0]
[236, 219]
p02959
u531258707
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n#print("A=",A)\n\n\ncount = 0\nfor i in range(N+1):\n if i == 0:\n taosita = B[i]-max((B[i]-A[i]),0)\n count = taosita\n B[i]= B[i]-taosita\n# print("i=0")\n elif i!=N\n \n taosita...
['Runtime Error', 'Accepted']
['s250016817', 's361231849']
[2940.0, 19284.0]
[17.0, 214.0]
[717, 718]
p02959
u534302832
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
["#!/usr/bin/env python\n\nN = input()\nN = int(N)\n\nA = []\nA = input().split()\nA = [int(n) for n in A]\nA.append(0)\n\nB = []\nB = input().split()\nB = [int(n) for n in B]\nB.append(0)\nB.append(0)\n\n#print('N=',n)\n#print('A=',A)\n\n\nmonster = 0\n\nfor i in range(N) :\n\tif A[i] < B[i] :\n\t\tmonster = monster +...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s260545193', 's790772981', 's907441614', 's967912766']
[18624.0, 19648.0, 18624.0, 19648.0]
[149.0, 123.0, 198.0, 180.0]
[510, 382, 538, 542]
p02959
u534953209
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(b) for b in input().split()]\nans = 0\nmons = 0\nyusha = 0\nfor i in range(N):\n\tmons = max(A[i] - yusha, 0)\n ans += min(yusha, A[i])\n ans += min(mons, B[i])\n yusha = max(0, B[i] - mons)\nprint(ans)', 'N = int(input())\nA = [int(a) for a i...
['Runtime Error', 'Accepted']
['s782136127', 's556468219']
[2940.0, 18468.0]
[17.0, 209.0]
[265, 293]
p02959
u537782349
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['a = int(input())\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\nd = 0\nfor i in range(a-1, -1, -1):\n d += min(b[i+1], c[i])\n b[i+1] -= min(b[i+1], c[i])\n c[i] -= min(b[i+1], c[i])\n\n d += min(b[i], c[i])\n b[i] -= min(b[i], c[i])\n c[i] -= min(b[i], c[i])\nprint(d)\n'...
['Wrong Answer', 'Accepted']
['s536642449', 's575936066']
[18476.0, 18468.0]
[297.0, 189.0]
[304, 253]
p02959
u539517139
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=0\nfor i in range(n-1):\n if a[i]<=b[i]:\n c+=a[i]\n d=b[i]-a[i]\n b[i+1]+=d\n else:\n c+=b[i]\nif b[n-1]=>a[n-1]:\n c+=a[n-1]\n x=b[n-1]-a[n-1]\n c+=min(a[n],x)\nelse:\n c+=b[n-1]\nprint(c)', 'n=int(input())\na=li...
['Runtime Error', 'Accepted']
['s951193774', 's448710553']
[2940.0, 18624.0]
[17.0, 217.0]
[277, 216]
p02959
u540799318
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\ndef cal(ans, n):\n ans += min(a[n], b[n])\n ans += b[n] - min(a[n], b[n])\n a[n+1] -= min(a[n], b[n])\n \nfor i in range(n):\n cal(ans,i)\n\nprint(ans)\n', 'import numpy as np\nn = int(input())\na...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s627653052', 's660613384', 's703154110', 's084328309']
[19156.0, 27364.0, 18476.0, 19116.0]
[166.0, 494.0, 159.0, 156.0]
[261, 538, 263, 251]
p02959
u545154994
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nenemys = list(map(int,input().split()))\npeople = list(map(int,input().split()))\nprint(enemys,people)\ncount = 0\nfor i in range(n):\n if enemys[i] - people[i] < 0:\n count += enemys[i]\n people[i]-=enemys[i]\n if enemys[i+1] - people[i] < 0:\n count += enemys[i+1...
['Wrong Answer', 'Accepted']
['s056757668', 's956548523']
[18624.0, 18476.0]
[180.0, 154.0]
[475, 454]
p02959
u547167033
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\ncnt=0\nif a[0]<b[0]:\n cnt+=a[0]\n a[0]=0\n a[1]-=b[0]-a[0]\nelse:\n cnt+=b[0]\n a[0]-=b[0]\nfor i in range(1,n-1):\n if a[i]<b[i]:\n cnt+=a[i]\n a[i]=0\n a[i+1]-=b[i]-a[i]\n else:\n cnt+=b[i]\n a[i]-=b[i]\ncnt+=...
['Wrong Answer', 'Accepted']
['s738147236', 's341882806']
[19004.0, 18624.0]
[126.0, 202.0]
[326, 209]
p02959
u548303713
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nb.append(0) \nnum=0\nc=0\nfor i in range(n):\n if a[i]<=c:\n num+=a[i]\n c=b[i]\n else:\n a[i]-=c\n if b[i]>=a[i]:\n num+=a[i]\n c=b[i]-a[i]\n else:\n num+=b[i]...
['Wrong Answer', 'Accepted']
['s261296880', 's150429288']
[18476.0, 18476.0]
[126.0, 138.0]
[416, 431]
p02959
u551066908
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\n\npower = 0\nmonster = 0\nif A[0] > B[0]:\n reslut = B[0]\n kurikoshi = 0\nelse:\n reslut = A[0]\n kurikoshi = B[0] - A[0] \n\nfor i in range(1, N):\n if A[i] - kurikoshi > 0:\n nokori = A[i] - kurikoshi\n resu...
['Runtime Error', 'Accepted']
['s400223210', 's430590853']
[19776.0, 19004.0]
[71.0, 133.0]
[616, 594]
p02959
u552738814
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['def solv():\n n = int(input())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n ans = 0\n\n for i in range(n+1):\n x = A[i] + A[i+1]\n ans += min(x,B[i])\n A[i+1] = min(A[i+1],max(x-B[i+1],0))\n print(ans)\n\nsolve()\n', 'def solv():\n n = int(input...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s284658257', 's384647414', 's446083571', 's750754741', 's793018567']
[9116.0, 24080.0, 8948.0, 24224.0, 24144.0]
[26.0, 136.0, 28.0, 138.0, 139.0]
[271, 276, 278, 275, 273]
p02959
u561083515
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\n\ncnt = 0\nfor i in range(N):\n if B[i] >= A[i]:\n cnt += A[i]\n B[i] -= A[i]\n else:\n cnt += B[i]\n B[i] = 0\n print(i,cnt,B[i])\n if B[i] == 0:\n continue\n if B[i] >= A...
['Wrong Answer', 'Accepted']
['s518531672', 's116182226']
[19648.0, 19648.0]
[369.0, 160.0]
[415, 393]
p02959
u573754721
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nc = 0\nfor i in range(n):\n ci = 0\n ci = min(a[i],b[i])\n c += ci\n b[i] -= ci\n ci1 = 0\n ci1 = min(a[i+1],b[i])\n c += ci1\n c[i+1] -= ci1\n\nprint(c)\n', 'n = int(input())\nL1 = list...
['Runtime Error', 'Runtime Error', 'Accepted']
['s015724764', 's128649305', 's422818865']
[19116.0, 18476.0, 19116.0]
[67.0, 199.0, 205.0]
[271, 236, 261]
p02959
u580362735
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\nfor i in range(N):\n ans += min(a[i]+a[i+1],b[i])\n A[i+1] -= max(0,min(A[i+1],B[i]-A[i]))\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 0\nfor i in ran...
['Runtime Error', 'Accepted']
['s803150245', 's408924873']
[18624.0, 18624.0]
[66.0, 190.0]
[196, 196]
p02959
u584083761
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\n\nM = list(map(int, input().split()))\n\nY = list(map(int, input().split()))\n\nsum_M = []\nfor i in range(0, N+1):\n if i == 0:\n p1 = max(0, Y[0] - M[0])\n sum_M.append(min(M[0], Y[0]) ) \n elif i < N:\n sum_M.append(min(M[i], Y[i] + p1) )\n p0 = \n p1 = min(Y[i], max(0, Y[i] - (M[i] + p1)) )...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s587822124', 's981282706', 's874493576']
[3060.0, 18624.0, 18476.0]
[17.0, 193.0, 174.0]
[389, 381, 379]
p02959
u585819925
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N=int(input())\nA,B= list(map(int,input().split())),list(map(int,input().split()))\n\nans = 0\nfor i,b in enumerate(B):\n temp = min(b,A[i]+A[i+1])\n ans += temp\n A[i+1] -= max(0, temp-A[i]) \nprint(an)\n', 'N=int(input())\nA,B= list(map(int,input().split())),list(map(int,input().split()))\n\nans = 0\nfor i...
['Runtime Error', 'Accepted']
['s975577581', 's597477489']
[19116.0, 18476.0]
[172.0, 165.0]
[245, 246]
p02959
u586662847
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['# import itertools\n# import math\n\nimport sys\ninput = sys.stdin.readline\n\n\ndef solve(N, A, B):\n defeat_monstar = 0\n for nn in range(N):\n if A[nn] >= B[nn]:\n defeat_monstar += B[nn]\n elif A[nn + 1] < (B[nn] - A[nn]):\n defeat_monstar += (A[nn + 1] + A[nn])\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s079541647', 's540380072', 's633263850']
[19376.0, 19376.0, 18624.0]
[106.0, 110.0, 121.0]
[719, 719, 911]
p02959
u593019570
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['a = int(input())\nb = list(map(int,input()))\nc = list(map(int,input()))\n\nans = 0\nfor i in range(a):\n ans += min(b[i],c[i])\n c[i] -= min(b[i],c[i])\n ans += min(b[i + 1], c[i])\n\nprint(ans)\n ', 'a = int(input())\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\n\nans = 0\nfor i in ...
['Runtime Error', 'Accepted']
['s943075733', 's741180978']
[5108.0, 18476.0]
[20.0, 230.0]
[193, 239]
p02959
u595289165
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nmonster = list(map(int, input().split()))\nsavers = list(map(int, input().split()))\nfirst = sum(monster)\nrest = []\nfor i in reversed(range(n)):\n monster_i = monster.pop()\n save_i = savers[i]\n \n monster_ii = max(monster_i - save_i, 0)\n \n save_ii = save_i - monster_ii\n r...
['Wrong Answer', 'Accepted']
['s969133038', 's764522667']
[18624.0, 19116.0]
[161.0, 171.0]
[473, 487]
p02959
u596297663
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = input()\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nscore = 0\nfor i in range(n):\n\tif B[i] >= A[i] + A[i+1]:\n\t\tscore = score + A[i] + A[i+1]\n A[i+1] = 0\n\telif B[i] <= A[i]:\n\t\tscore = score + B[i]\n\telse:\n\t\tscore = score + B[i]\n\t\tA[i+1] = A[i+1] + A[i] - B[...
['Runtime Error', 'Accepted']
['s150644541', 's095550800']
[2940.0, 18624.0]
[17.0, 144.0]
[309, 309]
p02959
u600717568
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nx=0\nfor i in range(N+1):\n if A[i]+A[i+1]<=B[i]:\n x+=A[i]+A[i+1]\n A[i+1]=0\n if A[i]>=B[i]:\n x+=B[i]\n if A[i]<B[i]:\n x+=B[i]\n A[i+1]=A[i+1]-(B[i]-A[i])\nprint(x)', 'N=int(input())\nA=list(map(int,input().split...
['Runtime Error', 'Accepted']
['s186107524', 's524716795']
[18376.0, 18476.0]
[192.0, 146.0]
[257, 289]
p02959
u605327527
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ncount = 0\n\nfor i in range(N):\n\n if A[i] >= B[i]:\n count += B[i]\n else:\n B[i] = B[i] - A[i]\n if B[i] >= A[i+1]:\n count += A[i+1]\n else:\n count += B[i]\n \n \nprint(count)', 'N = int(inpu...
['Wrong Answer', 'Accepted']
['s901200199', 's048178477']
[18476.0, 18624.0]
[106.0, 157.0]
[284, 351]
p02959
u608579392
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = [int(x) for x in input().split(" ")]\nB = [int(x) for x in input().split(" ")]\n\ncount = 0\nfor i in range(N):\n defeat = min([B[i], A[i]])\n B[i] -= defeat\n count += defeat\n defeat = min([B[i], A[i + 1]])\n A[i + 1] -= defeat\n B[i] -= defeat\n count += defeat\n\nprint(d...
['Wrong Answer', 'Accepted']
['s564805441', 's758995243']
[18624.0, 18624.0]
[217.0, 217.0]
[310, 340]
p02959
u614181788
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n if b[i] <= a[i]:\n ans += b[i]\n elif b[i] < a[i] + a[i+1]:\n a[i+1] = a[i] - b[i]\n ans += b[i]\n else:\n ans += a[i] + a[i+1]\n a[i+1] = 0\nprint(ans)',...
['Wrong Answer', 'Accepted']
['s462755271', 's872856949']
[18624.0, 18624.0]
[133.0, 143.0]
[303, 313]
p02959
u614320306
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import numpy as np\nN = int(input())\nA = [int(i) for i in input().split()] \nB = [int(i) for i in input().split()] \nC = np.zeros(N+1)\ncount = 0\nfor i in range(N):\n a = A[i] - B[i] -C[i]\n if a >= 0:\n count += B[i]\n else:\n count += A[i]\n if A[i] - C[i] < 0:\n C[i+1] = B[i]\n else:\n C...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s210409296', 's834262120', 's031430849']
[27300.0, 27300.0, 27352.0]
[680.0, 480.0, 709.0]
[415, 345, 413]
p02959
u616217092
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['from sys import stdin\n\n\ndef main():\n N = int(stdin.readline().rstrip())\n As = [int(x) for x in stdin.readline().rstrip().split()]\n Bs = [int(x) for x in stdin.readline().rstrip().split()]\n # result = 0\n\n print(sum(As))\n\n # if As[0] == 0 or Bs[0] == 0:\n \n # elif Bs[0] < As[0]:\n ...
['Wrong Answer', 'Accepted']
['s634099364', 's642245131']
[19648.0, 18436.0]
[70.0, 151.0]
[1186, 476]
p02959
u618107373
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import sys\nsys.setrecursionlimit(100000)\ninput=sys.stdin.readline\ndef intinput():return map(int,input().split())\n\n\nn=int(input())\na=list(intinput())\nb=list(intinput())\nans=0\nprint(a)\nfor i in range(n):\n if a[i]+a[i+1]<b[i]:\n ans+=a[i]+a[i+1]\n a[i+1]=0\n print(a,0)\n else:\n ...
['Runtime Error', 'Accepted']
['s157977863', 's454729420']
[147148.0, 19376.0]
[1758.0, 144.0]
[393, 346]
p02959
u625963200
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\nAs=list(map(int,input().split()))\nBs=list(map(int,input().split()))\nBs.append(0)\n\nans=0\nfor i in range(n):\n c=As[i]+As[i+1]\n if c>Bs[i]:\n ans+=Bs[i]\n if Bs[i]>As[i]:\n As[i+1]-=Bs[i]\n else:\n ans+=c\n As[i+1]=0\nprint(ans)', 'N = [int(i) for i in input().split()][0]\nA = ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s129552599', 's272373564', 's020278788']
[18624.0, 18624.0, 18624.0]
[127.0, 128.0, 142.0]
[253, 275, 259]
p02959
u626000772
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['import copy\nfrom itertools import accumulate\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nOA = copy.deepcopy(A)\n\n#print(M)\n\n#print(SM)\n\n\n#print()\n\ncount = 0\nfor i in range(N):\n nokori = A[i] - B[i]\n if A[i] - B[i] >= 0 :\n count += nokori\n ...
['Wrong Answer', 'Accepted']
['s917263262', 's854246310']
[18980.0, 18476.0]
[204.0, 153.0]
[539, 491]
p02959
u626337957
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nM = list(map(int, input().split()))\nH = list(map(int, input().split()))\n\nsum_m = 0\nrest = 0\nfor i in range(0, N):\n killed = min(H[i], M[i]-rest)\n rest = max(0, H[i]+rest-M[i])\n sum_m = killed\nsum_m += min(rest, M[-1])\n\nprint(sum_m)\n', 'N = int(input())\nM = list(map(int, input().split...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s185147678', 's538832908', 's659848371', 's764479549']
[18624.0, 18476.0, 18476.0, 18476.0]
[143.0, 146.0, 133.0, 136.0]
[252, 260, 326, 291]
p02959
u627325970
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nbeaten = 0\nB = B + [0, 0]\nfor i in range(N):\n if B[i] >= A[i]:\n beaten += A[i]\n beaten += min(A[i+1], B[i] - A[i])\n A[i+1] = max(0, A[i+1] - (B[i] - A[i]))\n else:\n beaten += B[i]', '...
['Wrong Answer', 'Accepted']
['s262674837', 's167048602']
[19116.0, 18624.0]
[187.0, 192.0]
[302, 316]
p02959
u627803856
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nans = 0\nfor i in range(n):\n if a[i] - b[i] >= 0:\n ans += b[i]\n else:\n if a[i+1] > b[i] - a[i]:\n ans += b[i]\n a[i+1] = a[i+1] - b[i] - a[i]\n else:\n ans += a...
['Wrong Answer', 'Accepted']
['s613534742', 's329305028']
[18476.0, 18476.0]
[144.0, 143.0]
[351, 343]
p02959
u634443822
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n=int(input())\na=([int(n) for n in input().split()])\nb=([int(n) for n in input().split()])\nb.append(0)\nr=0\nt=0\nx=0\nfor i in range(n+1):\n t=b[i]+x-a[i]\n if t>=0:\n r=r+a[i]\n x=max(b[i],t)\n else:\n r=r+b[i]+x\n x=0\nprint(r)', 'n=int(input())\na=([int(n) for n in input().split()])\nb=([int(n) ...
['Wrong Answer', 'Accepted']
['s399417641', 's675031926']
[18624.0, 19648.0]
[134.0, 130.0]
[233, 233]
p02959
u640922335
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nans=0\n\nfor i in range (N):\n ans+=min(A[N-i],B[N-1-i])\n if B[N-i-1]>A[N-i]:\n ans+=min(A[N-i-1],B[N-1-i]-A[N-i])\n A[N-i-1]-=min(A[N-i-1],B[N-1-i]-A[N-i])\n print(A)\n\nprint(ans)', 'N = int(input())...
['Runtime Error', 'Accepted']
['s800726821', 's809013387']
[149496.0, 24048.0]
[1636.0, 218.0]
[285, 272]
p02959
u650265349
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nA_copy = [x for x in A]\nB_copy = [y for y in B]\nfor i in range(N-1, -1, -1):\n if A_copy[i+1] > 0:\n A_copy[i+1] = max(A_copy[i+1]-B[i], 0)\n B_copy[i] = max(B_copy[i]-A[i+1], 0)\n if B_copy[i] > 0:\n a = A_copy...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s265709449', 's386944995', 's981609723', 's368514050']
[18476.0, 18752.0, 18476.0, 18476.0]
[221.0, 198.0, 280.0, 148.0]
[425, 405, 511, 684]
p02959
u653837719
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\nfor i in range(n):\n if a[i] + a[i + 1] < b[i]:\n ans += a[i] + a[i + 1]\n a[i + 1] = 0\n else:\n ans += b[i]\n if a[i] < b[i]:\n a[i + 1] -= b[i] - a[i]\n\nprint(ans)\n',...
['Runtime Error', 'Accepted']
['s431275890', 's336206361']
[2940.0, 19156.0]
[18.0, 136.0]
[301, 302]
p02959
u655048024
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nmonster = list(map(int,input().split()))\nbrave = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n if i == 0:\n kill = min(monster[0],brave[0])\n ans += kill \n brave -= kill\n else:\n kill = min(monster[i],brave[i])\n ans += kill\n brave[i] -= kill\n kill = min(m...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s073256448', 's819115992', 's945220972']
[19156.0, 18476.0, 19116.0]
[66.0, 181.0, 183.0]
[378, 386, 279]
p02959
u663230781
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['n = int(input())\nmonsters = [int(x) for x in input().rstrip("\\n").split(" ")]\ndamages = [int(x) for x in input().rstrip("\\n").split(" ")]\ntotal_monsters = sum(monsters)\nresult = 0\nremain = monsters[n]\nfor i in range(n-1,-1,-1):\n damage = damages[i]\n if damage <= remain:\n result += remain - damage\n ...
['Wrong Answer', 'Accepted']
['s587819781', 's433720552']
[18624.0, 19156.0]
[115.0, 135.0]
[484, 585]
p02959
u665038048
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['a = list(map(int, input().split()))\nb = list(map(int, input().split()))\ncnt = 0\na_ = []\nfor i in range(n):\n a_.append(a[i] + a[i+1])\nfor i in range(n):\n cnt += min(a_[i], b[i])\nprint(cnt)', 'n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ncnt = 0\ndp_1 = [0]*(...
['Runtime Error', 'Accepted']
['s029715756', 's980414373']
[14400.0, 21324.0]
[41.0, 192.0]
[193, 331]
p02959
u667084803
2,000
1,048,576
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat?
['N = int(input())\nA = list(map(int, input().split())) \nB = list(map(int, input().split())) + [0]\n\nans = min(A[0], B[0])\nrest = B[0] - ans\n \nfor i in range(N):\n \n curr = min(A[i+1], rest + B[i+1])\n rest = min(0, B[i+1] - curr)\n ans += curr\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s209896126', 's222103098', 's399304172']
[18624.0, 18624.0, 18476.0]
[170.0, 154.0, 184.0]
[307, 311, 374]