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
p02958
u932868243
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["n=int(input())\np=list(map(int,input().split()))\nt=list(range(1,n+1))\ncnt=0\nfor i in range(n):\n if p[i]!=t[i]:\n cnt+=1\nprint('Yes' if 0<=cnt<=2 else 'No')", "n=int(input())\np=list(map(in,input().split()))\nt=list(range(1,n+1))\ncnt=0\nfor pp in p:\n for tt in t:\n if pp!=tt:\n cnt+=1\nprint('Yes' ...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s414898681', 's626425649', 's627327078', 's681590047', 's861576793', 's383310768']
[3060.0, 2940.0, 3064.0, 2940.0, 3064.0, 3060.0]
[18.0, 17.0, 17.0, 18.0, 17.0, 17.0]
[157, 165, 365, 342, 326, 157]
p02958
u932945921
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["def main():\n n = int(input())\n p = list(map(int, input().split(' ')))\n c = 0\n for i in range(n):\n c += 0 if i+1 == p[i] else 1\n print(c)\n print('YES' if c <= 2 else 'NO')\n\n\nif __name__ == '__main__':\n main()", "def main():\n n = int(input())\n p = list(map(int, input().split(' ')))\n c = 0\n...
['Wrong Answer', 'Accepted']
['s762284949', 's191543895']
[2940.0, 2940.0]
[17.0, 17.0]
[219, 206]
p02958
u934868410
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n = int(input())\na = map(int, input().split())\n\nans = 0\nfor i in range(len(a)):\n if i != a[i]-1:\n ans += 1\n \nif ans <= 2:\n print("YES")\nelse:\n print("NO")', 'n = int(input())\na = map(int, input().split())\n\nans = 0\nfor i in a:\n if i != a[i]-1:\n ans += 1\n \nif ans <= 2:\n print("YES")...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s166251681', 's736216392', 's914114288', 's844820622']
[3060.0, 3064.0, 2940.0, 3060.0]
[17.0, 17.0, 18.0, 17.0]
[163, 151, 149, 169]
p02958
u937238023
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n = int(input())\np = list(map(int,input().split()))\ncnt = 0\nfor i in range(len(p)):\n if p[i] != i+1:\n cnt += 1\nif cnt==0 or cnt==2:\n print("Yes")\nelse:\n print("No")', 'n = int(input())\np = list(map(int,input().split()))\ncnt = 0\nfor i in range(len(p)):\n if p[i] != i+1:\n cnt += 1\nif cnt==0 or c...
['Wrong Answer', 'Accepted']
['s624990048', 's353479618']
[9176.0, 9164.0]
[30.0, 26.0]
[170, 171]
p02958
u942033906
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N = int(input())\nP = list(map(int,input().split()))\nQ = sorted(P)\ncnt = 0\nfor i in range(N):\n\tif P[i] != Q[i]:\n\t\tcnt +=1\n\nprint("Yes" if cnt <= 2 else "No")', 'N = int(input())\nP = list(map(int,input().split()))\nQ = sorted(P)\ncnt = 0\nfor i in range(N):\n\tif P[i] != Q[i]:\n\t\tcnt +=1\n\nprint("YES" if...
['Wrong Answer', 'Accepted']
['s091155212', 's611765661']
[2940.0, 3060.0]
[17.0, 17.0]
[156, 156]
p02958
u942767171
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["n = int(input())\np = list(map(int,input().split()))\n\nc = 0\n\nfor i in range(n) :\n if p[i] != n+1 :\n c += 1\n if c>2 :\n break\n\nif c==0 or c==2 :\n print('YES')\nelse :\n print('NO')", "n = int(input())\np = list(map(int,input().split()))\n\nc = 0\n\nfor i in range(n) :\n if p[i] != i+1 :\n c...
['Wrong Answer', 'Accepted']
['s120286757', 's401710604']
[3060.0, 3060.0]
[17.0, 19.0]
[189, 191]
p02958
u947327691
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n=int(input())\nA=list(map(int,input().split()))\n\nP=sorted(A)\ncnt=0\n\nfor i in range(len(A)):\n if A[i] != P[i]:\n cnt += 1\n\nprint("YES" if cnt <= 1 else "NO")\n', 'n=int(input())\nA=list(map(int,input().split()))\n\nP=sorted(A)\ncnt=0\n\nfor i in range(n):\n if A[i] != P[i]:\n cnt += 1\n\np...
['Wrong Answer', 'Accepted']
['s977387120', 's351301346']
[2940.0, 2940.0]
[17.0, 17.0]
[166, 161]
p02958
u948911484
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n = int(input())\np = list(map(int,input().split()))\nc = 0\nfor i in range(1,n+1):\n if p != i:\n c += 1\nif c == 2:\n print("YES")\nelse:\n print("NO")', 'n = int(input())\np = list(map(int,input().split()))\nc = 0\nfor i in range(1,n+1):\n if p != i:\n c += 1\nif c == 2 or c == 0:\n print("YES")\nelse:\...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s169568007', 's373666040', 's125734809']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[150, 160, 165]
p02958
u949981986
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N = int(input())\np = list(map(int, input().split()))\ncount = 0\nfor i in range(N):\n if i + 1 != p[i]:\n count += 1\nout = "No"\nif count == 0 or count == 2:\n out = "Yes"\n\nprint(out)', 'N = int(input())\np = list(map(int, input().split()))\ncount = 0\nfor i in range(N):\n if i + 1 != p[i]:\n ...
['Wrong Answer', 'Accepted']
['s212986668', 's658282707']
[3060.0, 3060.0]
[17.0, 17.0]
[190, 190]
p02958
u952708174
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\nP = [int(i) for i in input().split()]\n\npermulated = len(1 for k, p in enumerate(P, 1) if p != k)\nprint('YES' if permulated <= 2 else 'NO') ", "N = int(input())\nP = [int(i) for i in input().split()]\n\npermulated = len([1 for k, p in enumerate(P, 1) if p != k])\nprint('YES' if permulated <= 2 el...
['Runtime Error', 'Accepted']
['s374293901', 's231154924']
[2940.0, 2940.0]
[19.0, 17.0]
[157, 157]
p02958
u953379577
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n = int(input())\n\ns = list(map(int,input().split()))\n\nk = s.copy()\n\nk.sort(reverse = True)\n\nt = 0\n\nfor i in range(n):\n if s[i] != k[i]:\n t += 1\n \nif t<3:\n print("Yes")\nelse:\n print("No")', 'n = int(input())\ns = list(map(int,input().split()))\nt = s.copy()\nt.sort()\ncnt = 0\nf...
['Wrong Answer', 'Accepted']
['s019226458', 's345849156']
[3060.0, 8984.0]
[17.0, 27.0]
[209, 188]
p02958
u955248595
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\nSort = [str(x) for x in range(1,N+1)]\nP = [str(x) for x in input().split()]\n\nCount = 0\nfor T in range(0,N):\n if Sort[T] != P[T]:\n print(Sort[T])\n Count += 1\nif Count==0 or Count==2:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nSort = ''.join([str(x) for x i...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s025126293', 's046829435', 's117039124']
[9116.0, 9132.0, 9188.0]
[23.0, 27.0, 30.0]
[254, 297, 231]
p02958
u955865009
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['def check(n,l):\n flag = True\n for i in range(n-1):\n if l[i] > l[i+1]:\n flag = False\n break\n if flag:\n return True\n else:\n return False\n\nn = int(input())\nl = list(map(int,input().split()))\n\nflag = check(n,l)\nif flag:\n print("YES")\nelse:\n fo...
['Wrong Answer', 'Accepted']
['s000311333', 's915794505']
[9220.0, 9116.0]
[32.0, 27.0]
[566, 213]
p02958
u961945062
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["from collections import deque\nN = int(input())\nM = deque(map(int, input().split()))\n\nj = []\n\nprev = M.popleft()\n\nfor i in range(N-1):\n cor = M.popleft()\n if cor > prev:\n j.append(True)\n else:\n j.append(False)\n\n prev = cor\n\nif all(j) == True:\n print('Yes')\nelif j[0] == j...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s466395414', 's850140123', 's286133033']
[3316.0, 2940.0, 2940.0]
[21.0, 17.0, 17.0]
[352, 177, 180]
p02958
u962479059
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N=int(input())\np=list(map(int,input().split()))\nA=p.copy()\nA.sort()\nif p==A:\n print("YES")\nelse:\n i=p.index(max(p))\n min1=p[N-1]\n for j in range(N-2,0,-1):\n if p[j]<min1:\n min1=p[j]\n min_index=j\n p[i],p[min_index]=p[min_index],p[i]\n if p==A:\n print("YES")\n else:\n print("NO")...
['Runtime Error', 'Accepted']
['s600404106', 's134039808']
[3064.0, 3064.0]
[17.0, 18.0]
[301, 343]
p02958
u964521959
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['\nA = int(input())\n\nS = input()\n\nS_list = list(S)\nfor i in range(A-1):\n S_list.remove(" ")\n\nA_list = []\nfor i in range(A):\n A_list.append(i+1)\n\n\ncounter = 0\nfor i in range(A):\n if(A_list[i] != S_list[i]):\n counter = counter + 1\n\nif((counter == 0)or(counter == 2)):\n print("YES")\nelse:\n pri...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s094488595', 's182002645', 's475857849', 's813070727', 's843374734', 's354111647']
[3060.0, 3064.0, 3064.0, 3060.0, 3060.0, 3064.0]
[17.0, 18.0, 17.0, 17.0, 17.0, 17.0]
[373, 422, 421, 394, 351, 371]
p02958
u965033073
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N=input()\nList=[int(i) for i in input().split()]\ncount=0\nfor i in range(N):\n if i != List[i]:\n count += 1\nif count <=2:\n print("YES")\nelse:\n print("NO")\n ', 'N=int(input())\nList=[int(i) for i in input().split()]\ncount=0\nfor i in range(N):\n if i != List[i]:\n count += 1\nif count <=2:\n pri...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s157783530', 's607657211', 's821449928']
[2940.0, 2940.0, 3060.0]
[18.0, 18.0, 19.0]
[163, 169, 177]
p02958
u965840662
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N=int(input())\na=list(map(int,input().split()))\n\ncnt=0\nfor i in range(N):\n if(a[i]!=i):\n cnt+=1\nif(cnt<=2):\n print("YES")\nelse:\n print("NO")', 'N=int(input())\na=list(map(int,input().split()))\n\ncnt=0\nfor i in range(N):\n if(a[i]!=i+1):\n cnt+=1\nif(cnt<=2):\n print("YES")\nel...
['Wrong Answer', 'Accepted']
['s492220390', 's016301703']
[2940.0, 2940.0]
[17.0, 17.0]
[156, 158]
p02958
u968166680
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n N, *P = map(int, read().split())\n\n k = sum(1 for i, p in enumerate(P, 1) if i != p)\n\n if k > 2:\n print('NO')\n ...
['Wrong Answer', 'Accepted']
['s426540991', 's550346774']
[9072.0, 9136.0]
[27.0, 29.0]
[369, 369]
p02958
u969190727
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n=int(input())\nA=[int(i) for i in input().split()]\nB=[int(i) for i in input().split()]\nct=0\nfor i in range(n):\n if i+1!=P[i]:\n ct+=1\nprint("YES" if ct<=2 else "NO")', 'n=int(input())\nP=[int(i) for i in input().split()]\nct=0\nfor i in range(n):\n if i+1!=P[i]:\n ct+=1\nprint("YES" if ct<=2 else "NO")'...
['Runtime Error', 'Accepted']
['s998736192', 's739186796']
[3060.0, 2940.0]
[17.0, 17.0]
[168, 132]
p02958
u969848070
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["a = int(input())\nl = list(map(int, input().split()))\nx = l.sorted()\nfor i in range(a):\n if x[i] ==l[i]:\n b +=1\nif b ==2:\n print('YES')\nelse:\n print('NO')", "a = int(input())\nl = list(map(int, input().split()))\nx = sorted(l)\nb =0\nfor i in range(a):\n if x[i] !=l[i]:\n b +=1\nif b ==2 or b ==0:\n...
['Runtime Error', 'Accepted']
['s535212499', 's144358867']
[3316.0, 3060.0]
[21.0, 18.0]
[159, 172]
p02958
u970133396
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n = int(input().strip())\np = list(map(int, input().strip().split()))\n\nfor i in range(n):\n p[i]-=1\ncnt=0\nans="Yes"\nfor i,p_i in enumerate(p):\n if i==p_i:\n continue\n cnt+=1\n if cnt>1:\n ans="No"\n break\n for j,p_j in enumerate(p):\n if i==p_j:\n p[j]=p_i...
['Wrong Answer', 'Accepted']
['s515486664', 's342156637']
[3064.0, 3064.0]
[24.0, 17.0]
[353, 353]
p02958
u970197315
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["n = int(input())\np = [int(i) for i in input().split()]\ncount = 0\nfor i in range(n):\n print(i)\n if p[i] != i + 1:\n count += 1\nprint(count)\nif count == 0:\n print('YES')\n\nif count == 2:\n print('YES')\n\nif count > 2:\n print('No')\n", 'n=int(input())\np=list(map(int,input().split()))\no...
['Wrong Answer', 'Accepted']
['s394041196', 's301486676']
[3060.0, 9220.0]
[17.0, 38.0]
[247, 420]
p02958
u970198631
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\nMM = input().split()\ncount = 0\nlist1 =[]\nfor i in MM:\n a = int(i)\n list1.append(a)\nlist2 = sorted(list1)\nfor i,j in zip(list1,list2):\n \n if i != j:\n \n count +=1\nif count >2:\n print('No')\nelse:\n print('Yes')", "N = int(input())\nMM = input().split()\ncount = 0\nlist1 =[]\nf...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s306025916', 's475794138', 's261781580']
[9120.0, 9188.0, 9096.0]
[25.0, 27.0, 30.0]
[235, 235, 235]
p02958
u971715376
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N=int(input())\ns=list(map(int,input(),split()))\nt=sorted(s)\ng=0\nfor i in range(N):\n if t[i]!=s[i]:\n g+=1\nif g==2:\n print("YES")\nelse:\n print("NO")', 'N=int(input())\ns=list(map(int,input().split()))\nt=sorted(s)\ng=0\nfor i in range(N):\n if t[i]!=s[i]:\n g+=1\nif g==2 or g==0:\n print("YES")\nel...
['Runtime Error', 'Accepted']
['s647301568', 's617440715']
[3060.0, 3060.0]
[18.0, 17.0]
[152, 160]
p02958
u975485663
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N=int(input())\nP=list(map(int,input().split(\' \')))\ncount=0\nflg=1\n\nfor i in range(N):\n if P[i]!=i+1:\n if count==0:\n if P[P.index(i+1)]!=i+1:\n if flg:\n print("NO")\n flg=0\n else:\n P[i],P[P.index(i+1)]=P[P.index(i+1)],P[i]\n count+=1\n else:\n if...
['Wrong Answer', 'Accepted']
['s408700034', 's173941305']
[3064.0, 12488.0]
[17.0, 154.0]
[372, 171]
p02958
u975719989
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n=int(input())\np=list(map(int,input().split(())))\ncount=0\nfor i in range(n);\n if p[i] != i+1:\n count+=1\nif count==0 or count==2:\n print("Yes")\nelse:\n print("No")\n\n', 'n=int(input())\np=list(map(int,input().split(())))\ncount=0\nfor i in range(n);\n if p[i] != i+1:\n count+=1\nif c...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s060234715', 's653876227', 's763412005', 's128017197']
[2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0, 17.0]
[179, 181, 178, 176]
p02958
u981304949
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N = int(input())\nA = list(map(int, input().strip().split()))\ncount = 0\nfor i in range(N):\n if i == A[i]:\n count+=0\n else:\n count+=1\nif count == 2:\n print("YES")\nelse:\n print("NO")', 'N = int(input())\nA = list(map(int, input().strip().split()))\ncount = 0\nfor i in range(N):\n if i+1 == A[i]:\n ...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s495175255', 's751098584', 's897208950', 's680440873']
[2940.0, 3060.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0, 17.0]
[189, 220, 232, 222]
p02958
u981332890
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['def main():\n N = int(input())\n p = list(map(int, input().split()))\n\n diff = 0\n for i in range(N):\n if (i+1) != p[i]:\n diff += 1\n if (diff == 2) | (diff == 0):\n return "Yes"\n return "No"\nif __name__ == \'__main__\':\n print(main())', 'def main():\n N = int(in...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s057414686', 's994736140', 's498901860']
[3060.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0]
[273, 273, 273]
p02958
u982462877
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["\ns = input()\ns = int(s)\n\nnums = list(map(int,input().split()))\n\ncount = 0\n\nfor val in range(s):\n if val+1 != nums[val]:\n count +=1\n\nif count <= 2:\n print('Yes')\nelse: \n print('NO')\n", "s = int(input())\n\nnums = list(map(int,input().split()))\n\ncount = 0\n\nfor val in range(s):\n i...
['Wrong Answer', 'Accepted']
['s901241797', 's454393792']
[2940.0, 2940.0]
[17.0, 17.0]
[197, 191]
p02958
u982808037
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n=input()\np=list(map(int,input().split()))\ncnt=0\nfor i in range(len(p)):\n if(p[i]!=i):\n cnt+=1\n\nif(cnt<=2):\n print("YES")\nelse:\n print("NO")', 'n=input()\np=list(map(int,input().split()))\ncnt=0\nfor i in p:\n if(p[i]!=i):\n cnt+=1\n\nif(cnt<=2):\n print("YES")\nelse:\n print("NO")', 'n=input()\...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s161371709', 's291302512', 's561243173', 's967647006', 's526101422']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0, 17.0, 17.0]
[146, 134, 148, 141, 148]
p02958
u984276646
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\np = list(map(int, input().split()))\n\nq = 0\nfor i in range(len(p)):\n if p[i] != i+1:\n q += 1\n\nif q <= 2:\n print('Yes')\nelse:\n print('No')", "N = int(input())\np = list(map(int, input().split()))\n\nq = 0\nfor i in range(len(p)):\n if A[i] != i+1:\n q += 1\n\nif q <= 2:\n print('Y...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s224156630', 's545886083', 's483121818']
[2940.0, 3060.0, 2940.0]
[17.0, 17.0, 18.0]
[159, 159, 159]
p02958
u987170100
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = input()\nlst1 = list(map(int, input().split()))\nlst2 = sorted(lst1)\n\nn = 0\nfor x, y in zip(lst1, lst2):\n if x != y:\n n += 1\n if n > 2:\n break\n\nprint(n)\nif n > 2:\n print('NO')\nelse:\n print('YES')\n", "N = input()\nlst1 = list(map(int, input().split()))\nlst2 = sorted...
['Wrong Answer', 'Accepted']
['s029377763', 's814474093']
[3060.0, 2940.0]
[17.0, 17.0]
[232, 225]
p02958
u987637902
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["# ABC135\n# B 0 or 1 swap\nn = int(input())\np = list(map(int, input().split()))\nch = 0\nfor i in range(n):\n if (i+1) != p[i]:\n ch += 1\n\nif ch > 2:\n print('NO')\nelse:\n print('Yes')\n", "n = int(input())\np = list(map(int, input().split()))\nch = 0\nfor i in range(n):\n if (i+1) != p[i]:\n ...
['Wrong Answer', 'Accepted']
['s331491770', 's102440499']
[9108.0, 9168.0]
[29.0, 31.0]
[193, 168]
p02958
u989654188
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n = int(input())\np = list(map(int,input().split()))\n\ns=sorted(p)\ncnt=0\n\ndef jud(p,s,n,cnt):\n # print(p,s)\n for i in range(n):\n if s[i]!=p[i]:\n cnt+=1\n if cnt>2:\n return "No"\n return "Yes"\n\nprint(jud(p,s,n,cnt))', 'n = int(input())\np = list(map(int,input().s...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s199897808', 's625628528', 's417974695']
[3064.0, 3060.0, 3060.0]
[17.0, 18.0, 17.0]
[255, 253, 255]
p02958
u991269553
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["n = int(input())\np = list(map(int,input().split()))\na = 0\nfor i in range(1,n):\n if int(p[i]) + int(p[i-1]) != 2*i-1:\n a += 1\nif a <= 2:\n print('YES')\nelse:\n print('NO')\n", "n = int(input())\np = list(map(int,input().split()))\nq = sort(p)\nfor i in range(1,n):\n if p[i] != q[i]:\n ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s036598497', 's549637319', 's876431960', 's525818030']
[3064.0, 2940.0, 3060.0, 3060.0]
[18.0, 17.0, 17.0, 17.0]
[186, 172, 172, 188]
p02958
u994064513
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\nP = [ int(s) for s in input().split() ]\nP_S = sorted(P)\n\nif sum(map(lambda x: x[0] != x[1], zip(P,P_S))) <= 2:\n print('Yes')\nelse:\n print('No')\n", "N = int(input())\nP = [ int(s) for s in input().split() ]\nP_S = sorted(P)\n \nif sum(map(lambda x: x[0] != x[1], zip(P,P_S))) <= 2:\n p...
['Wrong Answer', 'Accepted']
['s382754173', 's825728717']
[2940.0, 3060.0]
[17.0, 18.0]
[167, 167]
p02958
u994910167
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\np = list(map(int, input().split()))\ncnt = 0\nl = list()\n\nfor i in range(N-1):\n if p[i] > p[i+1]:\n cnt += 1\n l.append(i)\n\nif cnt > 2:\n print('NO')\nif cnt < 2:\n print('YES')\nif cnt == 2:\n p[l[0]], p[l[1]+1] = p[l[1]+1], p[l[0]]\n cnt = 0\n for i in range(N-...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s742469992', 's764799371', 's935915938']
[3064.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0]
[456, 314, 473]
p02958
u995102075
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['N = int(input())\np = [int(i) for i in input().split()]\n\ncnt = 0\nfor i in range(0, N - 1):\n if p[i] > p[i + 1]:\n cnt += 1\n\nprint("YES" if cnt <= 1 else "NO")\n', 'N = int(input())\np = [int(i) for i in input().split()]\n\narray = [i for i in range(1, N + 1)]\ncnt = 0\n\nfor i in range(N):\n if p[i...
['Wrong Answer', 'Accepted']
['s102965779', 's014065866']
[2940.0, 2940.0]
[17.0, 17.0]
[167, 199]
p02958
u996434204
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
['n=int(input())\np=[int(x) for x in input().split()]\npp=[int(x+1) for x in range(n)]\n\nfor i in range(n):\n buf=i+1\n if buf != p[i]:\n p[p.index(buf)]=p[i]\n p[i]=buf\n break\n\nif pp==p:\n print("Yes")\nelse:\n print("No")', 'n=int(input())\np=[int(x) for x in input().split()]\npp=...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s199267108', 's363269078', 's602810193', 's963377506']
[3060.0, 2940.0, 3060.0, 3060.0]
[17.0, 18.0, 17.0, 21.0]
[244, 202, 203, 246]
p02958
u998733244
2,000
1,048,576
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
["N = int(input())\n\np = input().split()\n\np_sort = sorted(p)\n\ncount = 0\nfor i in range(N):\n if p[i]!=p_sort[i]: count+=1\n\nif count > 2: print('No')\nelse: print('Yes')\n", "N = int(input())\n\np = input().split()\n\np_sort = [i for i in range(1,N+1)]\n\ncount = 0\nfor i in range(N):\n if p[i]!=p_sort[i]:...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s293074426', 's983841806', 's530795995']
[2940.0, 3060.0, 2940.0]
[17.0, 17.0, 17.0]
[167, 183, 199]
p02959
u006880673
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\ntotal = 0\nfor i in range(N-1, -1, -1):\n total += min(A[i], B[i])\n B[i] -= min(A[i], B[i])\n if B[i] <= 0:\n break\n else:\n total += min(A[i+1], B[i])\n B[i] -= min(A[i+1], B[i])\n\nprint(...
['Wrong Answer', 'Accepted']
['s287294261', 's609621755']
[18624.0, 18624.0]
[69.0, 289.0]
[310, 280]
p02959
u007261655
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\n\nn=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nans = 0\nfor i in range(0,n):\n if A[i] <= B[i]:\n ans += A[i]\n B[i] -= A[i] \n if A[i+1] <= B[i]:\n ans += A[i+1]\n1 A[i+1] -= 0\n else:\n ans += B[i]\...
['Runtime Error', 'Accepted']
['s342708148', 's811493498']
[2940.0, 18908.0]
[17.0, 159.0]
[377, 375]
p02959
u007886915
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 -*-\nimport sys\nimport itertools\n\n#w=input()\nfrom operator import itemgetter\nfrom sys import stdin\n\n\nN=3\nM=3\ni=0\nj=0\nk=0\nans=0\n\n\nN=int(input())\n#A=int(input())\n#B=int(input())\n#print(N)\nmonster_list=list(map(int, input().split(" ")))\nbeat_list=list(map(int, input().split(" "))...
['Runtime Error', 'Accepted']
['s423288464', 's525504343']
[146404.0, 18752.0]
[1810.0, 223.0]
[4101, 4219]
p02959
u007991836
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]:\n ans += b[i]\n elif a[i] - b[i] >= a[i+1]:\n ans += b[i]\n a[i+1] -= (a[i] - b[i])\n else:\n ans += (a[i] + a[i+1])\n a[i+1] = 0\n\npr...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s514176068', 's756576933', 's905216898']
[18624.0, 18476.0, 19116.0]
[132.0, 198.0, 139.0]
[312, 327, 312]
p02959
u010069411
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 = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nguchoku=0\nfor i,b in enumerate(B):\n t = A[i] - b\n if t <= -1:\n zen = min(A[i+1] - t, 0)\n guchoku += A[i+1] - zen\n A[i+1] = zen\n guchoku += min(A[i], b)\nprint(guchoku)\n', 'N = int(inpu...
['Wrong Answer', 'Accepted']
['s193889329', 's183562359']
[19116.0, 18604.0]
[182.0, 187.0]
[288, 287]
p02959
u017624958
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\ndefeat = lambda Ai, Bi: min(A[i], B[i]) \n\ntotal = 0\nfor i in range(len(B)):\n num_of_defeated = defeat(A[i], B[i])\n A[i] -= num_of_defeated\n total += num_of_defeated\n\n remainder = B[i] - num_of_defeated\n ...
['Wrong Answer', 'Accepted']
['s937999324', 's359943681']
[18476.0, 18476.0]
[215.0, 201.0]
[429, 425]
p02959
u021019433
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?
['R = lambda: map(int, input().split())\ninput()\na = list(R())\ndef f():\n y = 0\n for u, v, w in zip(R(), a, a[1:]):\n x = min(v - y, u)\n y = x + min(w, u - x)\n yield x + y\nprint(sum(f()))\n', 'R = lambda: map(int, input().split())\ninput()\na = list(R())\ndef f():\n s = 0\n for x,...
['Wrong Answer', 'Accepted']
['s126964318', 's734595124']
[16576.0, 16576.0]
[119.0, 111.0]
[210, 206]
p02959
u024782094
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=sum(a)\nfor i in range(n):\n if a[i]>=b[i]:\n a[i]-=b[i]\n else:\n if a[i+1]-b[i]-a[i]<0:\n a[i+1]=0\n else:\n a[i+1]-=b[i]-a[i]\n\n a[i]=0\n\nprint(s-sum(a))', 'n=int(input())...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s253218569', 's758401924', 's860999426']
[18476.0, 19156.0, 18476.0]
[123.0, 123.0, 136.0]
[285, 272, 285]
p02959
u038408819
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 B[i] > A[i]:\n ans += A[i]\n if B[i] - A[i] > A[i + 1]:\n ans += A[i + 1]\n else:\n A[i + 1] -= B[i] - A[i]\n ans += B[i] - A[i]\n ...
['Wrong Answer', 'Accepted']
['s895840291', 's157331500']
[19116.0, 18624.0]
[160.0, 156.0]
[330, 367]
p02959
u042385277
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()))\ntotal = 0\n\nfor i in range(1,N) :\n if A[i] >= B[i]:\n total += B[0]\n elif A[i] + A[i+1] >= B[i]:\n total += B[i]\n A[i+1] = A[i] + A[i+1] - B[i]\n elif A[i] + A[i+1] < B[i] :\n total += ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s140719326', 's173543576', 's496385672']
[19004.0, 19004.0, 18476.0]
[145.0, 148.0, 148.0]
[353, 353, 351]
p02959
u054471580
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?
['ans = 0\nfor i in range(n):\n for j in range(i,i+2):\n tmp = b[i]\n b[i] -= a[j] \n if b[i]<=0:\n ans += tmp\n a[j] -= tmp\n break\n else:\n ans += a[j]\n a[j] = 0\n \nprint(ans)', 'n = int(input())\na = [int(i) fo...
['Runtime Error', 'Accepted']
['s248499140', 's649010777']
[2940.0, 18624.0]
[17.0, 213.0]
[269, 362]
p02959
u068727970
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\n\ncount = 0\nfor i in range(n-1):\n if a[i] - b[i] < 0:\n if a[i+1] - b[i] + a[i] < 0:\n b[i+1] += a[i+1]\n count += a[i]\n elif a[i] - b[i] >= 0:\n count += b[i]\n\nif b[n-1] ...
['Runtime Error', 'Accepted']
['s553296383', 's889974347']
[19004.0, 18624.0]
[127.0, 175.0]
[477, 583]
p02959
u075532540
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?
['num_lines = int(input())\nif num_lines<1 or num_lines>10**5:\n\tprint (\'Illegal\')\n\texit()\n#print(num_lines)\na=list(map(int,input().split(" ")))\nb=list(map(int,input().split(" ")))\n\nif len(a) !=num_lines +1 or len(b)!=num_lines:\n\tprint (\'Illegal\')\n\texit()\n\n#print (a)\n\ns=0\nr=0\nfor i in range(num_li...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s244167217', 's797908853', 's850669386']
[18624.0, 18396.0, 19004.0]
[183.0, 181.0, 170.0]
[403, 396, 389]
p02959
u077019541
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())\nAn = map(int,input().split())\nBn = map(int,input().split())\nans=0\nfor b in range(len(Bn)):\n left = min(An[b],Bn[b])\n ans+=left\n An[b]-=left\n Bn[b]-=left\n right = min(An[b+1],Bn[b])\n ans+=right\n An[b+1]-=right\n Bn[b]-=right\nprint(ans)\n', 'N = int(input())\nAn = li...
['Runtime Error', 'Accepted']
['s840111290', 's400297897']
[19372.0, 18476.0]
[36.0, 197.0]
[275, 287]
p02959
u077075933
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 c1 = min(A[i], B[i])\n c2 = min(A[i+1], max(0, B[i]-A[i]))\n A[i+1] -= c2\n count += c1+c2', 'N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ncoun...
['Wrong Answer', 'Accepted']
['s852060188', 's881846271']
[18624.0, 18624.0]
[188.0, 209.0]
[210, 223]
p02959
u080364835
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())\nal = list(map(int, input().split()))\nbl = list(map(int, input().split()))\nbl.append(0)\n\nmons = 0\nb0 = 0\n\nfor a, b in zip(al, bl):\n if a >= (b0 + b):\n mons += b0 + b\n else:\n mons += a\n b0 = b - max(a-b, 0)\n\nprint(mons)', 'n = int(input())\nal = list(map(int, i...
['Wrong Answer', 'Accepted']
['s922728495', 's416562034']
[19116.0, 24056.0]
[112.0, 146.0]
[261, 257]
p02959
u080883543
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?
['# C\nimport numpy as np\n\nn = int(input())\na = np.array(list(map(int, input().split())))\nb = np.array(list(map(int, input().split())))\n\naccum_a = a[1:]+a[:-1]\n\nfilled = np.zeros(n+1, dtype=np.bool)\nfilled[:n][accum_a < b] = True\nfilled[1:][accum_a < b] = True\nused = np.zeros(n, dtype=np.bool)\nused[accum_a ...
['Wrong Answer', 'Accepted']
['s693780544', 's835155455']
[23988.0, 27276.0]
[219.0, 304.0]
[385, 453]
p02959
u085717502
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# coding: utf-8\n\n# In[26]:\n\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\n# In[27]:\n\n\nans = 0\nfor i in range(N):\n ans += min(A[i], B[i])\n B[i] = max(B[i]-A[i])\n\n\n# In[ ]:\n\n\n\n\n', '#!/usr/bin/env python\n# coding: utf-8\n...
['Runtime Error', 'Accepted']
['s037988765', 's092552341']
[24064.0, 24008.0]
[67.0, 192.0]
[249, 325]
p02959
u090972687
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 = list(map(int, input().split()))\nheros = list(map(int, input().split()))\n\nkilled = 0\nattack = 0\nattack_l = [0, 0]\nfor i in range(0, n+1):\n if i != n:\n attack_l[i%2] = heros[i]\n attack = attack_l[0] + attack_l[1]\n if (monsters[i] - attack) < 0:\n killed += monsters[i]\n...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s059838497', 's159245404', 's782471741', 's686616913']
[18752.0, 18476.0, 19000.0, 19004.0]
[154.0, 164.0, 170.0, 169.0]
[658, 668, 683, 670]
p02959
u095478438
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()))\n\nA_0 = A_list.pop(0)\n#print(A_0)\n#print(A_list)\nA_list[0] = A_list[0] + A_0\n#print(A_list)\n\ntaos = 0\nnokori = 0\nkeep = 0\n\nfor i, (a, b) in enumerate(zip(A_list, B_list)):\n if i == 0:\n if a >= b:\n ...
['Wrong Answer', 'Accepted']
['s952938654', 's330593924']
[18752.0, 19244.0]
[131.0, 112.0]
[574, 421]
p02959
u098588273
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()))\nnum=0\nfor i in range(n):\n num+=min(a[i],b[i])\n b[i]=max(0,b[i]-a[i])\n num+=min(b[i]-a[i],a[i+1])\n a[i+1]=max(0,a[i+1]-b[i])\nprint(num)', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nnu...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s036121549', 's785217480', 's957063510']
[18476.0, 18476.0, 18624.0]
[241.0, 233.0, 258.0]
[219, 219, 214]
p02959
u105210954
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 sa = a[i] - b[i]\n \n if sa < 0:\n b[i] -= a[i]\n ans += a[i]\n sa2 = a[i+1] - b[i]\n \n if sa2 < 0:\n ans += a[i+1]\n a[i+1] = 0\n else:\n a[i+1] -= sa2\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s274657067', 's487563471', 's228265987']
[18624.0, 3064.0, 18624.0]
[167.0, 17.0, 151.0]
[383, 338, 352]
p02959
u106103668
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\nx = min(A[0],B[0])\nans += x\nfor j in range(N-1):\n i = j+1\n x = min(A[i],B[i-1]-x)\n ans += x\n x = min(A[i]-x,B[i])\n ans += x\ni = i+1\nx = min(A[i],B[i-1]-x)\nans += x', 'N = int(input())\nA = l...
['Runtime Error', 'Runtime Error', 'Accepted']
['s109287544', 's791252588', 's184153792']
[18624.0, 18476.0, 18624.0]
[161.0, 164.0, 171.0]
[276, 288, 220]
p02959
u112007848
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())\nmons = list(map(int, input().split(" ")))\nyuu = list(map(int, input().split(" ")))\ncount = 0\nfor i in range(a):\n if yuu[i] >= mons[i]:\n yuu[i] -= mons[i]\n mons[i] = 0\n count += mons[i]\n if yuu[i] >= mons[i + 1]:\n yuu[i] -= mons[i + 1]\n mons[i + 1] = 0\n count ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s270409952', 's650515940', 's650183512']
[19004.0, 19156.0, 19004.0]
[154.0, 235.0, 161.0]
[443, 420, 465]
p02959
u113255362
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())\nList_A = list(map(int, input().split()))\nList_B = list(map(int, input().split()))\nres = 0\nfor i in range(N-1):\n if List_A[i] >= List_B[i]:\n res += List_B[i]\n else:\n res += List_A[i]\n if List_A[i+1] >= List_B[i]-List_A[i]:\n res += List_B[i]-List_A[i]\n List_A[i+1] = List...
['Wrong Answer', 'Accepted']
['s873286403', 's956141653']
[24208.0, 24152.0]
[145.0, 139.0]
[405, 403]
p02959
u114366889
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()))\nsum_A = sum(A)\nB = list(map(int,input().split()))\ncount = 0 \n\n\nfor i in range(N):\n\tcount += i\n\n\n', 'N = int(input())\nA = list(map(int,input().split()))\nsum_A = sum(A)\nB = list(map(int,input().split()))\n\n\nfor i in range(N):\n\t\n\tif B[i]-A[i] >= 0:...
['Wrong Answer', 'Accepted']
['s555639591', 's707028270']
[18476.0, 18476.0]
[82.0, 140.0]
[148, 341]
p02959
u116002573
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\ntot = 0\nfor i in range(N):\n if A[i] <= B[i]:\n tot += A[i]\n B[i] -= A[i]\n A[i] = 0\n else:\n tot += B[i]\n B[i] = 0\n A[i] = A[i] - B[i]\n if B[i] >= 0:\n if A[i+...
['Runtime Error', 'Accepted']
['s715008948', 's046788897']
[3064.0, 19648.0]
[17.0, 183.0]
[489, 494]
p02959
u116233709
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(input().split()))\nb=list(map(input().split()))\ncnt=0\nfor i in range(0,n-2):\n if b[i]>=b[i+1]:\n if b[i]<=a[i+1]:\n cnt+=b[i]\n a[i+1]-=b[i]\n else:\n cnt+=a[i+1]\n cnt+=min(a[i],(b[i]-a[i+1]))\n else:\n if b[i]<=a[i]:\n cnt+=b[i]\n else:\n cnt...
['Runtime Error', 'Accepted']
['s910004913', 's967268492']
[11200.0, 19156.0]
[26.0, 157.0]
[380, 300]
p02959
u121879791
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=list(map(int,input().split()))\nheroes=list(map(int,input().split()))\nans=0\nfor i in range(n):\n if heroes[i]>monsters[i]:\n ans+=monsters[i]\n ans+=min(heroes[i],monsters[i+1])\n monsters[i+1]-=min(heroes[i],monsters[i+1])\n else:\n ans+=heroes[i]\nprint(a...
['Wrong Answer', 'Accepted']
['s704500132', 's439845911']
[24104.0, 24144.0]
[141.0, 152.0]
[310, 341]
p02959
u123745130
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?
['ns=0\nright=0\nleft=0\nfor i in range(n):\n left=min(a[i],b[i])\n ans+=left\n a[i]-=left\n b[i]-=left\n \n right=min(a[i+1],b[i])\n ans+=right\n a[i+1]-=right\n b[i]-=right\nprint(ans)', 'ans=0\nright=0\nleft=0\nfor i in range(n):\n left=min(a[i],b[i])\n ans+=left\n a[i]-=left\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s395542510', 's427972610', 's115539068']
[3064.0, 3064.0, 19156.0]
[17.0, 17.0, 196.0]
[198, 199, 281]
p02959
u127499732
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 main():\n import sys\n n = int(input())\n a = list(map(int.sys.stdin.readline().split()))\n b = list(map(int.sys.stdin.readline().split()))\n \n count=0\n \n for i in range(n):\n c1 = a[i] \n c2 = a[i+1]\n h = b[i]\n ans+=min(c1,h) \n if h>c1:\n ans+=min(h-c1,c2)\n a[i+1]=max...
['Runtime Error', 'Accepted']
['s946537973', 's768963753']
[3064.0, 19376.0]
[17.0, 146.0]
[367, 387]
p02959
u131464432
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())\nC = tuple(map(int,input().split()))\nB = list(map(int,input().split()))\nA = list(C)\nfor i in range(N)[::-1]:\n if A[i+1] > B[i]:\n A[i+1] -= B[i]\n elif B[i] < A[i]+A[i+1]:\n A[i+1] = 0\n A[i] -= B[i] - A[i+1]\n else:\n A[i] = 0\n A[i+1] = 0\nans = 0\nfo...
['Wrong Answer', 'Accepted']
['s381860316', 's231585414']
[25460.0, 25476.0]
[136.0, 139.0]
[354, 356]
p02959
u136843617
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 solve():\n N = int(input())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n maximum = sum(A)\n for i in reversed(range(N)):\n reduce2 = max(0, A[i + 1] - B[i])\n reduce1 = max(0, A[i] - B[i] + reduce2)\n A[i + 1] = reduce2\n A[i] = reduce1\n...
['Wrong Answer', 'Accepted']
['s789963773', 's989848293']
[18476.0, 19156.0]
[127.0, 129.0]
[392, 349]
p02959
u137228327
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\nprint(A,B)\nadd = 0\nfor i in range(len(B)):\n if B[i] > A[i]:\n add += A[i]\n B[i] -= A[i]\n if A[i+1] > B[i]:\n add+=B[i]\n A[i+1] -= B[i]\n else:\n add += A[i...
['Wrong Answer', 'Accepted']
['s426790774', 's226921754']
[24308.0, 24128.0]
[144.0, 132.0]
[446, 364]
p02959
u138863123
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())\nH = [int(a) for a in input().split()]\n\nif (N == 1):\n print('Yes')\n exit()\nhmax=H[0]\nfor i in range(N - 1): \n if (hmax - H[i + 1]) > 1:\n print('No')\n exit()\n hmax = max(hmax, H[i + 1])\nprint('Yes')\n", 'N = int(input())\nA = [int(a) for a in input().split()]\nB =...
['Wrong Answer', 'Accepted']
['s043267447', 's643119971']
[14400.0, 18624.0]
[89.0, 252.0]
[241, 291]
p02959
u141633765
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\nB=B+[0]\ncounter = 0\nprint(B) \nfor i in reversed(range(1, N+1)):\n dif = A[i] - B[i]\n if dif > 0:\n B[i] += min(dif, B[i-1])\n B[i-1] -= min(dif, B[i-1]) \n counter += min(A[i], B[i])\ncounter +...
['Wrong Answer', 'Accepted']
['s166585131', 's462682704']
[18624.0, 18624.0]
[217.0, 219.0]
[345, 335]
p02959
u166621202
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 town_a = a[i]\n town_b = b[i+1]\n power = b[i]\n if power > town_a:\n ans += town_a\n power -= town_a\n else:\n ans += power\n continue\n if power > tow...
['Runtime Error', 'Accepted']
['s747083334', 's471665082']
[18476.0, 19116.0]
[136.0, 145.0]
[415, 417]
p02959
u183840468
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\nal = [int(i) for i in input().split()]\nbl = [int(i) for i in input().split()]\n\nans = 0\nfor i in range(n):\n if bl[i] <= al[i]:\n ans += bl[i]\n elif bl[i] > al[i] and bl[i] <= al[i] + al[i+1]:\n ans += bl[i]\n al[i+1] = al[i] + al[i+i] - bl[i]\n else:\n ans...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s291313087', 's485266926', 's687273723', 's969870974']
[19648.0, 19648.0, 18624.0, 19156.0]
[113.0, 109.0, 158.0, 156.0]
[373, 374, 346, 345]
p02959
u190167135
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=min(A[0],B[0])\nB[0]-=ans\nfor i in range(N-1):\n score=min(A[i+1],B[i]+B[i+1])\n ans+=score\n B[i+1]-=min(0,score-B[i])\nprint(ans+min(B[N-1],A[N]))', 'N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,inp...
['Wrong Answer', 'Accepted']
['s960127924', 's016894606']
[24176.0, 24176.0]
[156.0, 145.0]
[237, 237]
p02959
u193886067
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\nmaxCount = 0\nfor i in range(0, n):\n \n if a[i] > b[i]:\n maxCount += b[i]\n b[i] = 0\n else:\n maxCount += a[i]\n b[i] -= a[i]\n \n if a[i + 1] > b[i]:\n maxCount += b[i]...
['Wrong Answer', 'Accepted']
['s580617889', 's074967038']
[19244.0, 19116.0]
[217.0, 149.0]
[443, 477]
p02959
u193927973
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()))\npre=sum(A)\n\nfor i in range(N):\n if B[i]<=A[i]:\n A[i]-=B[i]\n else:\n A[i+1]=max(0, B[i]-A[i])\n A[i]=0\nprint(sum(A)-pre)', 'N=int(input())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\npre=su...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s781027749', 's950656566', 's505131211']
[24032.0, 24236.0, 24172.0]
[103.0, 121.0, 116.0]
[211, 218, 218]
p02959
u197078193
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 print(i)\n if A[i] > B[i]:\n ans += B[i]\n A[i] -= B[i]\n B[i] -= B[i]\n else:\n ans += A[i]\n B[i] -= A[i]\n A[i] -= A[i]\n if A[i+1] > B[i]:\n...
['Wrong Answer', 'Accepted']
['s517429160', 's558600968']
[19000.0, 18752.0]
[266.0, 179.0]
[458, 445]
p02959
u197237612
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?
[' = 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] < b[i]:\n ab = b[i] - a[i]\n if a[i+1] > ab:\n ans += b[i]\n a[i+1] -= ab\n else:\n ans += a[i] + a[i+1]\n a[i+1] = 0\n else:\n ans += b[i]\n\nprint(ans)...
['Runtime Error', 'Accepted']
['s505706047', 's190274743']
[8880.0, 24080.0]
[24.0, 135.0]
[302, 309]
p02959
u200527996
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 print(A[i],B[i])\n if A[i] >= B[i]:\n ans += B[i]\n if A[i] < B[i]:\n ans += A[i]\n if A[i+1] >= (B[i] - A[i]):\n A[i+1] -= B[i] - A[i]\n ans +=...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s176166486', 's307442178', 's667686074']
[18476.0, 18624.0, 18624.0]
[297.0, 310.0, 170.0]
[393, 392, 372]
p02959
u201928947
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\nprint(a)\nprint(b)\nfor i in range(n):\n if b[i] >= a[i] + a[i+1]:\n count += a[i] + a[i+1]\n a[i+1] = 0\n elif b[i] > a[i] and b[i] < a[i] + a[i+1]:\n count += b[i]\n a[i+1] -= b[i] ...
['Wrong Answer', 'Accepted']
['s193875390', 's515003033']
[18476.0, 18752.0]
[192.0, 159.0]
[384, 353]
p02959
u202826462
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\nsumbuster = 0\nfor i in range(n):\n ibuster=0\n j = i\n ibuster += min(b[i],a[j]+a[j+1])\n print(ibuster)\n if(b[i] >= (a[j]+a[j+1])):\n a[j+1] = 0\n sumbuster += ibuster\n\nprint(sumbuster)', 'n = int...
['Wrong Answer', 'Accepted']
['s910259959', 's244913934']
[18476.0, 18624.0]
[225.0, 230.0]
[293, 280]
p02959
u207608961
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 monstors = [int(i) for i in input().split()]\n heros = [int(i) for i in input().split()]\n init_monstor = sum(monstors)\n\n for i in range(N):\n if monstors[i] >= heros[i]:\n monstors[i] -= heros[i]\n heros[i] = 0\n else:\n heros[i] -= monstors[i]\n monstor...
['Runtime Error', 'Accepted']
['s395574790', 's747889963']
[2940.0, 19648.0]
[17.0, 152.0]
[517, 511]
p02959
u212328220
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()))\n\nA_list.reverse()\nB_list.reverse()\n\nkilled_enemies = 0\nkilled_num = 0\nfor i in range(N):\n if killed_num + B_list[i] >= A_list[i]:\n killed_num = (killed_num + B_list[i]) - A_list[i]\n killed_e...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s242187103', 's348782406', 's006846392']
[18396.0, 18476.0, 18624.0]
[114.0, 124.0, 161.0]
[544, 625, 345]
p02959
u213401801
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\nprint(a)\nprint(b)\ndef battle(a,ai,b):\n if a+ai <= b:\n count=a+ai\n ai=0\n elif a<=b:\n ai=ai-(b-a)\n count=b\n else:\n ai=ai\n count=b\n return ai,count\n \nfor i in range(n):\n c=0\n a[i+1],c=bat...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s377601099', 's867932062', 's387869110']
[18476.0, 2940.0, 18624.0]
[160.0, 17.0, 139.0]
[347, 329, 330]
p02959
u217627525
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-1):\n c=min(a[i],b[i])\n a[i]-=c\n b[i]-=c\n d=min(b[i],a[i+1])\n a[i+1]-=d\n ans+=c+d\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=0\...
['Wrong Answer', 'Accepted']
['s058761797', 's369408737']
[18624.0, 19116.0]
[200.0, 178.0]
[213, 211]
p02959
u219157465
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 main():\n n = int(input())\n monsters = [int(x) for x in input().split()]\n heroes = [int(x) for x in input().split()]\n\n ans_list = [0] * (n+1)\n rest_hero = 0\n for i in range(n+1):\n if i == n:\n now_hero = rest_hero\n else:\n now_hero = rest_hero + heroes...
['Wrong Answer', 'Accepted']
['s570106599', 's751078911']
[18624.0, 19004.0]
[96.0, 127.0]
[600, 741]
p02959
u223904637
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]:\n ans+=a[i]\n ans+=min(a[i+1],b[i]-a[i])\n a[i+1]=max(a[i+1]-(b[i]-a[i]),0)\n else:\n ans+=b[i]\nprint(ans)', 'n=int(input())\na=list(map(int,input().split...
['Runtime Error', 'Accepted']
['s395217563', 's192825673']
[2940.0, 19244.0]
[17.0, 205.0]
[258, 259]
p02959
u224346910
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 main():\n num_monster = 0\n res = 0 \n for i in range(N):\n a = A[i] - res \n b = B[i]\n if b <= a: \n num_monster += b\n res = 0\n elif b <= a+A[i+1]: \n num_monster += b\n res = b - a\n else: \n num_monster +...
['Runtime Error', 'Accepted']
['s763947379', 's859728780']
[3060.0, 19116.0]
[18.0, 95.0]
[545, 646]
p02959
u253952966
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\nsum_ = 0\nrest = 0\n\nfor i in range(n):\n if a[i] >= b[i] + rest:\n sum_ += b[i] + rest\n rest = 0\n elif a[i] >= rest:\n sum_ += a[i]\n rest = b[i]\n else:\n sum_ += a[i]\n rest = b[i]\n\nsum_ += min(a...
['Wrong Answer', 'Accepted']
['s241011556', 's219434027']
[18624.0, 18624.0]
[112.0, 120.0]
[322, 337]
p02959
u259755734
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 calc(a, b, c):\n if a < b:\n b -= a \n c += a \n a = 0 \n else:\n a -= b \n c += b \n b = 0\n return a, b, c \n\nc = 0\nfor i in reversed(range(N)):\n A[i+1], B[i], c = calc(A[i+1], B[i], c)\n A[i], B[i], c = calc(A[i], B[i], c)\n\nprint(c)', 'N = int(input...
['Runtime Error', 'Accepted']
['s223226886', 's925213707']
[3064.0, 18476.0]
[17.0, 177.0]
[285, 399]
p02959
u268981216
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()))\n#blaver\nb=list(map(int,input().split()))\nprint(a,b)\nans=0\nfor i in range(n):\n if a[i] < b[i]:\n b[i] -= a[i]\n ans += a [i]\n if a[i+1] < b[i]:\n ans += a[i+1]\n a[i+1] = 0\n \n else:\n ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s280692592', 's365546394', 's952350086', 's424901996']
[18396.0, 18624.0, 18376.0, 18624.0]
[167.0, 177.0, 172.0, 149.0]
[401, 408, 391, 375]
p02959
u270589070
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\ncounter =[]\nfor i,Bi in enumerate(B):\n counter.append(Bi-A[i]-A[i+1])\n \nID=counter.index(max(counter))\n#print(ID)\n\ncounter =0\nfor i in range(ID,len(B),1):\n if A[i] >= B[i]:\n counter +=B[i]\n A[i] -= B[i]\n B[i]...
['Wrong Answer', 'Accepted']
['s325651605', 's845931347']
[18476.0, 19004.0]
[195.0, 163.0]
[881, 441]
p02959
u271430213
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=c=0\nfor i in range(N+1):\n a=A[i]\n b=B[i]\n ans+=min(a,c)\n a=max(a-c,0)\n ans+=min(a,b)\n c=max(b-a,0)\nprint(ans)\n', 'N=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))+[0]\na...
['Runtime Error', 'Accepted']
['s449867163', 's275720323']
[18624.0, 19244.0]
[192.0, 202.0]
[213, 217]
p02959
u271934630
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\nsys.setrecursionlimit(10 ** 7)\n\ni_i = lambda: int(i_s())\ni_l = lambda: list(map(int, stdin.readline().split()))\ni_s = lambda: stdin.readline().rstrip()\n\nN = i_i()\nA = i_l()\nB = i_l()\n\nans = 0\nfor i in range(len(B)):\n print('ans', ans)\n if A[i] >= B[i]:\n ans +=...
['Wrong Answer', 'Accepted']
['s793953560', 's591615636']
[18624.0, 19376.0]
[287.0, 193.0]
[635, 476]