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
p02597
u665452497
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["def main():\n N=int(input())\n c=list(input())[::-1]\n \n #x...WR\n #o...RR, RW, WW\n \n \n \n res=0\n cR=c.count('R')\n cW=c.count('W')\n \n l,r=0,N-1\n while True:\n if c[l]=='W':\n if c[r]=='R':\n c[l],c[r]='R','W'\n res+=1\n else:\n r-=1\n else:\n l+=1\n \n print(min(cR,cW,res))\n \n \nif __name__ == '__main__':\n main()", "def main():\n N=int(input())\n c=list(input())\n \n #x...WR\n #o...RR, RW, WW\n \n \n \n res=0\n cR=c.count('R')\n cW=c.count('W')\n \n l,r=0,N-1\n while l!=r:\n if c[l]=='W':\n if c[r]=='R':\n c[l],c[r]='R','W'\n res+=1\n else:\n r-=1\n else:\n l+=1\n \n print(min(cR,cW,res))\n \n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s640232631', 's065299848']
[11972.0, 10748.0]
[84.0, 63.0]
[506, 500]
p02597
u667687319
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = input()\n\nwi = c.find('W')\nri = c.rfind('R')\n\nif wi == -1 or ri == -1:\n print(0)\nelse:\n ans = 0\n while wi < ri:\n wi += 1\n wi = c[wi:].find('W')\n ri = c[:ri].rfind('R')\n ans += 1\n\n print(ans, c)", "n = int(input())\nc = input()\n\nwi = c.find('W')\nri = c.rfind('R')\n\nif wi == -1 or ri == -1:\n print(0)\nelse:\n ans = 0\n while wi < ri:\n wi += 1\n wi = c[wi:].find('W') + wi\n ri = c[:ri].rfind('R')\n ans += 1\n\n print(ans)"]
['Wrong Answer', 'Accepted']
['s160290566', 's775653902']
[9352.0, 9312.0]
[1548.0, 1107.0]
[253, 255]
p02597
u682271925
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['def main():\n n = int(input())\n li = list(input())\n i = 0\n j = n-1\n ans = 0\n while(i < j):\n while(li[i] == "R" and i < j):\n i += 1\n while(li[j] == "W" and i < j):\n j -= 1\n li[i] = "R"\n li[j] = "W"\n ans += 1\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()', 'def main():\n n = int(input())\n li = list(input())\n i = 0\n j = n-1\n ans = 0\n while(i < j):\n while(li[i] == "R" and i < j):\n i += 1\n while(li[j] == "W" and i < j):\n j -= 1\n if li[i] == "W" and li[j] == "R":\n li[i] = "R"\n li[j] = "W"\n ans += 1\n print(li)\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()', 'def main():\n n = int(input())\n li = list(input())\n i = 0\n j = n-1\n ans = 0\n while(i < j):\n while(li[i] == "R" and i < j):\n i += 1\n while(li[j] == "W" and i < j):\n j -= 1\n if li[i] = "W" and li[j] = "R":\n li[i] = "R"\n li[j] = "W"\n ans += 1\n print(ans) \n\nif __name__ == \'__main__\':\n main()', 'def main():\n n = int(input())\n li = list(input())\n i = 0\n j = n-1\n ans = 0\n while(i < j):\n while(li[i] == "R" and i < j):\n i += 1\n while(li[j] == "W" and i < j):\n j -= 1\n if li[i] == "W" and li[j] == "R":\n li[i] = "R"\n li[j] = "W"\n ans += 1\n print(ans) \n\nif __name__ == \'__main__\':\n main()']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s171098598', 's449299088', 's557167612', 's912925898']
[10780.0, 141220.0, 9040.0, 10500.0]
[66.0, 3659.0, 29.0, 67.0]
[287, 345, 332, 334]
p02597
u690184681
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = input()\n\nleft = 0\nright = len(c)-1\n\ncount=0\nif (right+1)%2==0:\n while (left-1)!=right:\n print(right,left)\n if c[left]=='R':\n left+=1 \n elif c[right]=='W':\n right-=1\n elif c[left]=='W' and c[right]=='R':\n left+=1\n right-=1\n count+=1\nelse :\n while left!=right:\n if c[left]=='R':\n left+=1 \n elif c[right]=='W':\n right-=1\n elif c[left]=='W' and c[right]=='R':\n left+=1\n right-=1\n count+=1\n\nans = count\nprint(ans)", "N = int(input())\nc = input()\n\nleft = 0\nright = len(c)-1\n\ncount=0\nif (right+1)%2==0:\n while (left-1)!=right:\n if c[left]=='R':\n left+=1 \n elif c[right]=='W':\n right-=1\n elif c[left]=='W' and c[right]=='R':\n left+=1\n right-=1\n count+=1\nelse :\n while left!=right:\n if c[left]=='R':\n left+=1 \n elif c[right]=='W':\n right-=1\n elif c[left]=='W' and c[right]=='R':\n left+=1\n right-=1\n count+=1\n\n\nprint(count)\n"]
['Wrong Answer', 'Accepted']
['s876719059', 's292501293']
[9524.0, 9476.0]
[169.0, 72.0]
[594, 560]
p02597
u744920373
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n\nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n\ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num)\n \n return cnt\n\n\nwhile True:\n mid = (left + right) // 2\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid += 1\n break\n left = mid\n else:\n right = mid\n\nif mid == 0:\n print(mid)\n exit()\n\nright = mid\nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n elif tmp == K:\n right = mid\n else:\n left = mid\n mid = (left + right) // 2', "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\n#from itertools import accumulate #list(accumulate(A))\n\nN = ii()\nS = input()\n\nnum_r = S.count('R')\nans = num_r\n\nfor i in range(num_r):\n if S[i] == 'R':\n ans -= 1\n\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s323412105', 's637952644']
[9228.0, 9504.0]
[23.0, 61.0]
[1267, 705]
p02597
u756782069
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = input()\nW = c.count('W')\nprint(c[:R].count('W'))", "N = int(input())\nc = input()\nW = c.count('W')\nR = c.count('R')\nprint(c[:R].count('W'))"]
['Runtime Error', 'Accepted']
['s104848919', 's976671977']
[9448.0, 9452.0]
[25.0, 29.0]
[69, 86]
p02597
u770308589
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nA = list(input())\nprint(C[:C.count(\'R\')].count("W"))\n', 'n = int(input())\nC = input()\nprint(C[:C.count(\'R\')].count("W"))']
['Runtime Error', 'Accepted']
['s761702834', 's877961022']
[10748.0, 9392.0]
[29.0, 30.0]
[70, 63]
p02597
u788068140
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['# N = 8\n# S = "WRWWRWRR"\n#\n# N = 2\n# S = "RR"\n#\n# N = 4\n# S = "WWRR"\n\nN = int(input())\nS = input()\n\n# N = 2\n# S = "WW"\n\ndef calculate(n, s):\n arr = list(s)\n\n RNum = arr.count("R")\n\n leftW = 0\n rightR = RNum\n\n result = []\n for i in range(n):\n if arr[i] == "R":\n rightR -= 1\n if arr[i] == "W":\n leftW += 1\n\n if leftW == 0 or rightR == 0:\n result.append(0)\n continue\n\n result.append(max(leftW, rightR))\n\n print(min(result))\n\n\ncalculate(N, S)\n', 'def calculate(n, s):\n arr = list(S)\n\n RNum = arr.count("R")\n\n leftW = 0\n rightR = RNum\n\n result = []\n for i in range(n):\n if arr[i] == "R":\n rightR -= 1\n if arr[i] == "W":\n leftW += 1\n\n result.append(max(leftW, rightR))\n\n print(min(result))\n\n\ncalculate(N, S)\n', "N = int(input())\nS = input()\n\n\ndef calculate(n, s):\n arr = list(s)\n result = []\n\n\n leftW = 0\n rightR = arr.count('R')\n\n\n if rightR == 0:\n print(0)\n return\n\n for i in range(n):\n val = arr[i]\n\n if val == 'R':\n rightR -= 1\n\n if val == 'W':\n leftW += 1\n\n result.append(max(leftW,rightR))\n\n if len(result) == 0:\n print(0)\n else:\n print(min(result))\n\ncalculate(N, S)\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s117670339', 's896675080', 's383159268']
[18548.0, 8976.0, 18848.0]
[98.0, 25.0, 93.0]
[532, 323, 463]
p02597
u794066762
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\ns=input()\nif s.count('R')==0 or s.count('W')==0:\n print(0)\nelse:\n a= s.count('W')\n w=s.index('W')\n b= s[w:].count('R')\n if b==0:\n print(0)\n else:\n c = s[(w+1):].count('W')\n t=min(b,c)\n print(min(t,a))\n\n", "n=int(input())\ns=input()\nif s.count('R')==n:\n print(0)\nelse:\n w=s.index('W')\n s=s[w:]\n a= s.count('W')\n b=s[len(s)-a:].count('W')\n print(a-b)\n"]
['Wrong Answer', 'Accepted']
['s727712877', 's065152865']
[9428.0, 9468.0]
[34.0, 34.0]
[263, 160]
p02597
u802234211
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N = int(input())\nstone = list(map(str,input()))\nind = [""]*2\nind[0] = list()\nind[1] = list()\nR = 0\nW = 0\nfor i in range(N):\n if(stone[i]=="W"):\n ind[0].append(i)\n W += 1\n else:\n ind[1].append(i)\n R += 1\nind[1].reverse()\nans = 0\n\nif(W != R):\n print(min(W,R))\nelse:\n for i in range(N):\n if(ind[0][i]>ind[1][i]):\n break\n ans+=1\n print(ans)\n', 'N = int(input())\nstone = list(map(str,input()))\nind = [""]*2\nind[0] = list()\nind[1] = list()\nR = 0\nW = 0\nfor i in range(N):\n if(stone[i]=="W"):\n ind[0].append(i)\n W += 1\n else:\n ind[1].append(i)\n R += 1\nnewR = 0\nfor i in range(R):\n if(i != ind[1][i]):\n break\n newR+= 1\n\n\nnewind =list(reversed(ind[1]))\nans2 = 0\n\n# print(W,R,newR)\n# print(ind[1],newind)\nif(newR != R):\n ans1 = min(W,R-newR)\nelse:\n ans1 = min(W,R)\nif(ans1 != 0):\n for i in range(N//2):\n if(ind[0][i]>newind[i]):\n break\n ans2+=1\n # print(ans)\nprint(min(ans1,ans2))\n']
['Runtime Error', 'Accepted']
['s898184182', 's633571859']
[18640.0, 20324.0]
[99.0, 125.0]
[405, 617]
p02597
u805011545
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import sys\nN = int(input())\nc = [str(x) for x in list(input())]\nR = sum([1 for i, x in enumerate(c) if(x=='R')])\nW = 0\nif(R==N)or(R==0):\n print(0)\n sys.exit()\nans = R\ni = 0\nwhile True:\n if(c[i] == 'W'):\n W += 1\n else:\n R -= 1\n n_ans = max(W,R)\n if(n_ans>ans):\n print(ans)\n sys.exit()\n ans = n_ans\n i += 1\n", "import sys\nN = int(input())\nc = [str(x) for x in list(input())]\nR = sum([1 for i, x in enumerate(c) if(x=='R')])\nW = 0\nif(R==N)or(R==0):\n print(0)\n sys.exit()\nans = R\ni = 0\nwhile True:\n if(i==N):\n print(ans)\n sys.exit()\n if(c[i] == 'W'):\n W += 1\n else:\n R -= 1\n n_ans = max(W,R)\n if(n_ans>ans):\n print(ans)\n sys.exit()\n ans = n_ans\n i += 1"]
['Runtime Error', 'Accepted']
['s022643164', 's946875427']
[12356.0, 12348.0]
[133.0, 138.0]
[325, 366]
p02597
u811143577
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nS = list(input().strip())\n\nr = S.count('R')\nw = S.count('W')\n\nans = min(r, w)\n\nri = S.index('R')\nr2 = S[ri:].count('W')\n\nans = min(ans, r2)\nprint(ans)\n\n", "N = int(input())\nS = list(input().strip())\n\nr = S.count('R')\nw = S.count('W')\n\nans = min(r, w)\n\nri = S.index('R')\nr2 = S[:ri].count('R')\nw2 = S[ri:].count('W')\n\nans = min(ans, r2+w2)\nprint(ans)\n\n", "N = int(input())\nS = list(input().strip())\n\nl = 0\nr = N-1\nans = 0\nwhile l < r:\n if S[l] == 'W' and S[r] == 'R':\n ans += 1\n l += 1\n r -= 1\n while l < N and S[l] != 'W':\n l += 1\n while r >= 0 and S[r] != 'R':\n r -= 1\n\nprint(ans)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s243451351', 's876933040', 's179335702']
[12072.0, 12092.0, 10768.0]
[44.0, 38.0, 100.0]
[169, 195, 270]
p02597
u813993459
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['import collections\n\nc=input()\n\ntmp=collections.Counter(c)\n\ncount_r=0\ncount_w=0\nans=0\ndis_r=0\n\nfor i in c:\n if dis_r == tmp["R"]:\n break\n \n elif i == "W":\n if count_r<=tmp["R"]-count_r:\n ans+=1\n dis_r+=1\n else:\n count_r+=1\n dis_r+=1\nprint(ans)', 'import collections\n\nc=input()\nc=input()\n\ntmp=collections.Counter(c)\n\ncount_r=0\ncount_w=0\nans=0\ndis_r=0\n\nfor i in c:\n if dis_r == tmp["R"]:\n break\n \n elif i == "W":\n if count_r<=tmp["R"]:\n ans+=1\n dis_r+=1\n else:\n ans+=1\n else:\n count_r+=1\n dis_r+=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s148928739', 's624265322']
[9384.0, 9592.0]
[26.0, 93.0]
[308, 343]
p02597
u823885866
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: map(int, sys.stdin.readline().split())\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\nn = ri()\ns = rr()\nprint(s[n//2].count('W'))", "import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: map(int, sys.stdin.readline().split())\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\nn = ri()\ns = rr()\ncnt = 0\ni = 0\nj = n-1\nwhile True:\n while s[i] == 'R':\n i += 1\n if i >= n:\n break\n while s[j] == 'W':\n j -= 1\n if j < 0:\n break\n if i < j:\n cnt += 1\n i += 1\n j -=1\n else:\n break\nprint(cnt)\n"]
['Wrong Answer', 'Accepted']
['s801886983', 's043912815']
[27260.0, 27292.0]
[114.0, 167.0]
[444, 697]
p02597
u844789719
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import itertools\nN = int(input())\nS = input()\ncnt = 0\nwhile True:\n while i < N and S[i] == 'R':\n i += 1\n while 0 <= j and S[j] == 'W':\n j -= 1\n if j < i:\n break\n cnt += 1\n i += 1\n j -= 1\nprint(cnt)\n", "import itertools\nN = int(input())\nS = input()\ncnt = i = 0\nj = N - 1\nwhile True:\n while i < N and S[i] == 'R':\n i += 1\n while 0 <= j and S[j] == 'W':\n j -= 1\n if j < i:\n break\n cnt += 1\n i += 1\n j -= 1\nprint(cnt)\n"]
['Runtime Error', 'Accepted']
['s312600496', 's461973706']
[9436.0, 9416.0]
[27.0, 89.0]
[237, 251]
p02597
u854294899
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["import sys\ninput = sys.stdin.readline\nn = int(input())\ns = list(input())\nans = 0\nfor i in range(n - 1):\n idx = n - 1 - i\n if s[idx] == 'W' and s[idx + 1] == 'R':\n ans += 1\n s[idx] = 'R'\nprint(ans)", "import sys\ninput = sys.stdin.readline\nn = int(input())\ns = input()\nans = 0\nfor i in range(n - 1):\n idx = n - 1 - i\n if s[idx] == 'W' and s[idx + 1] == 'R':\n ans += 1\n s[idx] = 'R'\nprint(ans)\n", "import sys\ninput = sys.stdin.readline\nn = int(input())\ns = input()\nans = 0\nfor i in range(n - 1):\n if s[i] == 'W' and s[i + 1] == 'R':\n ans += 1\nprint(ans)\n ", "import sys\ninput = sys.stdin.readline\nn = int(input())\ns = input()\nans = 0\nr = [0] * n\nw = [0] * n\nfor i in range(n):\n if s[i] == 'W':\n w[i] += 1\n else:\n r[i] += 1\nfor i in range(1, n):\n w[i] += w[i - 1]\n r[i] += r[i - 1]\nrn = r[n - 1]\nans = n\nif rn == 0:\n ans = 0\nfor i in range(n):\n c = (i + 1)\n ri = r[i]\n left = rn - ri\n need = c - ri\n ans = min(ans, max(left, need)) \n\nprint(ans)\n"]
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s376158883', 's784612471', 's907730111', 's228500145']
[10768.0, 9328.0, 9336.0, 24816.0]
[91.0, 71.0, 61.0, 231.0]
[204, 199, 162, 402]
p02597
u865343871
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nC = list(input())\nW = 0\nR = 0\nfor i in range(int(N/2)+1):\n if C[i] == 'W':\n W += 1\nfor i in range(int(N/2+1),N):\n if C[i] == 'R':\n R += 1\nif W>R:\n print(R)\nelse:\n print(W)\n\n", "N = int(input())\nC = list(input())\nW = 0\nR = 0\nfor i in range(0,int(N/2+1)):\n if C[i] == 'W':\n W += 1\nfor i in range(int(N/2+1),N):\n if C[i] == 'R':\n R += 1\nif W >= R:\n print(R)\nelse:\n print(W)\n\n\n", 'N = int(input())\nC = list(input())\nW = 0\nR = 0\nfor i in range(0,int(N/2)):\n if C[i] == \'W\':\n W += 1\n print(C[i])\nprint("-------------")\nfor i in range(int(N/2),N):\n if C[i] == \'R\':\n R += 1\n print(C[i])\nif W>=R:\n print(R)\nelse:\n print(W)\n', "N = int(input())\nC = list(input())\ncount = list()\n\nfor i in range(N):\n W = 0\n R = 0\n for j in range(0,int(N/2+1)):\n if C[j] == 'W':\n W += 1\n for j in range(int(N/2+1),N):\n if C[j] == 'R':\n R += 1\n if W > R:\n count.append(R)\n else:\n count.append(W)\n\nprint(min(count))", 'N = int(input())\nC = list(input())\ncount = list()\nW = 0\nR = 0\n\nfor i in C:\n if i == "R":\n R += 1\n\nif R == 0:\n count.append(0)\n\nfor i in C:\n\n if i == "W":\n W += 1\n else:\n R -= 1\n\n if W <= R:\n count.append(R)\n else:\n count.append(W)\n\nprint(min(count))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s024144384', 's181334267', 's492627909', 's542794107', 's925034577']
[10748.0, 10660.0, 10668.0, 10692.0, 18624.0]
[59.0, 58.0, 103.0, 2206.0, 94.0]
[216, 222, 269, 334, 302]
p02597
u874644572
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\ns = input()\nl = 0\nr = n - 1\nans = 0\nwhile l < r:\n while l < r && s[l] == 'R':\n l += 1\n while l < r && s[r] == 'W':\n r -= 1\n ans += 1\n l += 1\n r -= 1\n\nprint(ans)", "n = int(input())\ns = input()\nl = 0\nr = n - 1\nans = 0\n\nwhile l < r:\n while l < r and s[l] == 'R':\n l += 1\n while l < r and s[r] == 'W':\n r -= 1\n if l >= r:\n break\n ans += 1\n l += 1\n r -= 1\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s554171609', 's196392707']
[8976.0, 9332.0]
[23.0, 66.0]
[206, 238]
p02597
u888092736
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['from collections import Counter\n\n\nN = int(input())\nC = input()\nC_cntr = Counter(C)\n\nans = 0\nfor i in range(C_cntr["R"]):\n\u3000if C[i] == "W":\n ans += 1\n\nprint(ans)\n', 'from collections import Counter\n\n\nN = int(input())\nc = input()\ncntr = Counter(c)\n\nans = 0\nfor c, r in zip(c, "R" * cntr["R"]):\n if c != r:\n ans += 1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s539962175', 's255685042']
[8844.0, 9712.0]
[20.0, 53.0]
[169, 170]
p02597
u891202624
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['N=int(input())\nc=list(input())\nprint(c)\ni=0\ncount1=0\ncount2=0\nfor i in c:\n if i=="R":\n count1+=1\nfor j in range(count1):\n if c[j]=="R":\n count2+=1\nprint(count1-count2)', 'N=int(input())\nc=list(input())\ni=0\ncount1=0\ncount2=0\nfor i in c:\n if i=="R":\n count1+=1\nfor j in range(count1):\n if c[j]=="R":\n count2+=1\nprint(count1-count2)']
['Wrong Answer', 'Accepted']
['s787624228', 's234179441']
[12304.0, 10740.0]
[89.0, 80.0]
[187, 178]
p02597
u909359131
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n=int(input())\na=input()\nprint(a)\na=list(a)\nprint(a)\nt=0\ns=0\nfor i in range(0,n):\n if a[i]=="R":\n t=t+1\n\nfor i in range(0,t):\n if a[i]!="R":\n s=s+1\nprint(s)', 'n=int(input())\na=input()\nprint(a)\na=list(a)\nprint(a)\nt=0\ns=0\nfor i in range(0,n):\n if a[i]=="R":\n t=t+1\nfor i in range(0,t):\n if a[i]!="R":\n s=s+1\nprint(s)', 'n=int(input())\na=input()\n\na=list(a)\n\nt=0\ns=0\nfor i in range(0,n):\n if a[i]=="R":\n t=t+1\n\nfor i in range(0,t):\n if a[i]!="R":\n s=s+1\nprint(s)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s386281582', 's434138611', 's886167073']
[12556.0, 12612.0, 10684.0]
[83.0, 84.0, 74.0]
[176, 175, 160]
p02597
u909514237
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nc = input()\nW = 0\nR = c.count('R')\nif R == 0 or W == 0:\n print(0)\n exit()\n\nans = N\nt = 0\nfor i in range(N):\n if c[i] == 'W':\n W += 1\n else:\n R -= 1\n t = max(R,W)\n ans = min(ans, t)\nprint(ans)", 'N = int(input())\nc = input()\n\nR_r = c.count("R")\nW_l = 0\nans = N\nfor i in range(N+1):\n t = max(R_r,W_l)\n ans = min(ans, t)\n if R_r == 0:\n break\n if c[i] == "R":\n R_r -= 1\n else:\n W_l += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s204432210', 's190312750']
[9288.0, 9400.0]
[28.0, 129.0]
[220, 213]
p02597
u911619829
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["N = int(input())\nC=list(input())\nL=0\nR=0\nRR=0\nX=0\n for i in range(N):\n L=i\n R=RR\n if L>=N-1-R:\n break\n if C[i]=='W':\n for ii in range(N-L-R):\n if C[N-1-R-ii]=='R':\n C[L]='R'\n C[N-1-R-ii]='W'\n X+=1\n break\n RR+=1\n if L>=N-1-R:\n break\nprint(X)", "N = int(input())\nC=list(input())\nW=(C.count('W'))\nR=N-W\nWW=0\nRR=0\nX=[0]*(N-1)\nif W>0 and R>0:\n for i in range(N-1):\n if C[i]=='W':\n WW+=1\n RR=(N-i-1)-(W-WW)\n X[i]=max(WW,RR)\nprint(min(X))"]
['Runtime Error', 'Accepted']
['s194747961', 's741073785']
[8964.0, 18212.0]
[25.0, 128.0]
[377, 202]
p02597
u914214809
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['widx = []\nridx = []\ns = input()\nfor i, char in enumerate(s):\n if char == "W":\n widx.append(i)\n else:\n ridx.append(i)\ncount = 0\ni = 0\nj = len(ridx) - 1\nwhile i < len(widx) and j >= 0 and widx[i] < ridx[j]:\n i += 1\n j -= 1\n count += 1\nprint(count)\n ', 'widx = []\nridx = []\nn = int(input())\ns = input()\nfor i, char in enumerate(s):\n if char == "W":\n widx.append(i)\n else:\n ridx.append(i)\ncount = 0\ni = 0\nj = len(ridx) - 1\nwhile i < len(widx) and j >= 0 and widx[i] < ridx[j]:\n i += 1\n j -= 1\n count += 1\nprint(count)']
['Wrong Answer', 'Accepted']
['s779174097', 's351959830']
[9048.0, 17292.0]
[28.0, 104.0]
[259, 273]
p02597
u919730120
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n=int(input())\nc=list(input())\nl,r=0,n-1\nans=0\nwhile l<r:\n while c[l]!='W':\n l+=1\n if l>n-1:\n break\n while c[r]!='R' or r>=0:\n r-=1\n if r<0:\n break\n if l<r:\n ans+=1\n l+=1\n r-=1\nprint(ans)", "n=int(input())\nc=list(input())\nl,r=0,n-1\nans=0\nwhile l<r:\n while c[l]!='W':\n l+=1\n if l>n-1:\n break\n while c[r]!='R':\n r-=1\n if r<0:\n break\n if l<r:\n ans+=1\n l+=1\n r-=1\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s330153294', 's511735907']
[10784.0, 10772.0]
[91.0, 69.0]
[267, 259]
p02597
u922769680
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n=int(input())\nC=list(input())\nif C.count("W")==0:\n print(0)\nelif C.count("W")==1:\n if C[-1]=="W":\n print(0)\n else:\n print(1)\nelse:\n if n%2==0:\n tmpw=C.count("W")\n print(tmpw,C)\n C=C[tmpw:]\n print(tmpw,C)\n print(C.count("R"))\n else:\n tmpw=C.count("W")\n print(tmpw,C)\n C=C[tmpw-1:]\n print(tmpw,C)\n print(C.count("R"))\n \n ', 'n=int(input())\nC=list(input())\nif C.count("W")==0:\n print(0)\nelif C.count("W")==1:\n if C[-1]=="W":\n print(0)\n else:\n print(1)\nelse:\n tmpw=C.count("W")\n #print(tmpw,C)\n #if tmpw%2==0:\n C=C[(n-tmpw):]\n #print(tmpw,C)\n print(C.count("R"))\n #else:\n #C=C[tmpw-1:]\n #print(tmpw,C)\n #print(C.count("R"))\n ']
['Wrong Answer', 'Accepted']
['s457047375', 's085823997']
[12464.0, 11868.0]
[63.0, 43.0]
[429, 414]
p02597
u928784113
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nimport math\nfrom copy import deepcopy\nimport queue\nimport numpy as np\n\nMod = 1000000007\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1] \nfor i in range(2, 10**5 + 1):\n fact.append((fact[-1] * i) % Mod)\n inv.append((-inv[Mod % i] * (Mod // i)) % Mod)\n factinv.append((factinv[-1] * inv[-1]) % Mod)\n \ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n \n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[y] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\ndef pow_k(x, n):\n \n if n == 0:\n return 1\n \n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n return K * x\ndef main(): #startline-------------------------------------------\n n = int(input())\n s = input()\n print(min(s[:n//2].count("W"),s[n//2+1:].count("R")))\n \n \nif __name__ == "__main__":\n main() ', 'import itertools\nfrom collections import deque,defaultdict,Counter\nfrom itertools import accumulate\nimport bisect\nfrom heapq import heappop,heappush,heapify\nimport math\nfrom copy import deepcopy\nimport queue\nimport numpy as np\n\nMod = 1000000007\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1] \nfor i in range(2, 10**5 + 1):\n fact.append((fact[-1] * i) % Mod)\n inv.append((-inv[Mod % i] * (Mod // i)) % Mod)\n factinv.append((factinv[-1] * inv[-1]) % Mod)\n \ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n \ndef sieve_of_eratosthenes(n):\n if not isinstance(n,int):\n raise TypeError("n is not int")\n if n<2:\n raise ValueError("n is not effective")\n prime = [1]*(n+1)\n for i in range(2,int(math.sqrt(n))+1):\n if prime[i] == 1:\n for j in range(2*i,n+1):\n if j%i == 0:\n prime[j] = 0\n res = []\n for i in range(2,n+1):\n if prime[i] == 1:\n res.append(i)\n return res\n \n \nclass UnionFind:\n def __init__(self,n):\n self.parent = [i for i in range(n+1)]\n self.rank = [0 for i in range(n+1)]\n \n def findroot(self,x):\n if x == self.parent[x]:\n return x\n else:\n y = self.parent[x]\n y = self.findroot(self.parent[x])\n return y\n \n def union(self,x,y):\n px = self.findroot(x)\n py = self.findroot(y)\n if px < py:\n self.parent[y] = px\n else:\n self.parent[px] = py\n \n def same_group_or_no(self,x,y):\n return self.findroot(x) == self.findroot(y)\ndef pow_k(x, n):\n \n if n == 0:\n return 1\n \n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n \n return K * x\ndef main(): #startline-------------------------------------------\n n = int(input())\n s = input()\n print(s.count("R")-s[:s.count("R")].count("R"))\n \n \nif __name__ == "__main__":\n main() ']
['Wrong Answer', 'Accepted']
['s234902171', 's807233314']
[39252.0, 38708.0]
[244.0, 219.0]
[2164, 2158]
p02597
u941644149
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nC = input()\nc_R = 0\nc_W = 0\nfor c in C:\n if c == "R": c_R += 1\n else: c_W += 1\nans = min(c_R, c_W)\n\n\nif C[0] + C[1] == "WR":\n C[2:].find("WR") != -1:\n C = list(C)\n C[0] = "R"\n C[C[2:].find("WR") + 1] = "W"\n C = "".join(C)\n \nind1 = C.find("RWR")\nif ind1 != -1:\n ind2 = C[ind1 + 2:].find("WR")\nelse:\n ind2 = -1\n\n\nwhile ((ind1 != -1) & (ind2 != -1)):\n C = list(C)\n C[ind1 + 1] = "R"\n C[ind2 + 1] = "W"\n C = "".join(C)\n\n ind1 = C.find("RWR")\n if ind1 != -1:\n ind2 = C[ind1 + 2:].find("WR")\n else:\n ind2 = -1\n\n\n \n\n\nc_R = 0\nc_W = 0\nfor c in C:\n if c == "R": c_R += 1\n else: c_W += 1\nans = min(ans,c_R, c_W)\n\n\n\n\n\n\n\n\n \n', 'n = int(input())\ns = input()\na = 0\nb = 0\nfor c in s:\n if c == "R": a += 1\nans = max(a,b)\nfor i in range(n):\n if s[i] == "R": a -= 1\n else: b += 1\n ans = min(ans, max(a, b))\nprint(ans)\n\n\n\n\n\n\n\n\n \n']
['Runtime Error', 'Accepted']
['s102021982', 's561313406']
[9036.0, 9336.0]
[27.0, 137.0]
[705, 209]
p02597
u942356554
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = list(input())\nc = c[::-1]\ncou = 0\nfor i in range(len(c)/2):\n if c[i] == "R":\n cou += 1\nprint(cou)', 'n = int(input())\nc = list(input())\nc2 = c[::-1]\ncou = 0\nfor i in range(len(c)//2):\n if c2[i] == "R":\n cou += 1\nfor i in range(len(c)//2):\n if c[i] == "W":\n if c[i+1] == "R":\n cou += 1\nprint(cou)', 'n = int(input())\nc = list(input())\nprint(c[:c.count("R")].count("W"))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s134025814', 's641451652', 's553376670']
[12056.0, 11944.0, 11844.0]
[29.0, 63.0, 40.0]
[128, 225, 69]
p02597
u953379577
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['import collections as c\nn = int(input())\ns = list(input())\ncnt = 0\n\nwhile c.Counter(s[:cnt+1])["W"]<c.Counter(s[cnt:])["R"]:\n cnt += 1\n \nprint(cnt)', 'n = int(input())\ns = list(input())\ncnt = 0\nfor i in s:\n if i == "R":\n cnt += 1\n else:\n break\n\na = s.count("R")-cnt\nb = 0\n\nwhile s[:b+1].count("W") < s[b:].count("R"):\n b += 1\n\nprint(min(a,b))', 'n = int(input())\ns = input()\nprint(s.count("R")-s[:s.count("R")].count("R"))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s498647946', 's742036698', 's746724854']
[12504.0, 12180.0, 9452.0]
[2206.0, 2206.0, 31.0]
[153, 214, 77]
p02597
u958869885
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["n = int(input())\nc = list(map(int, input().split()))\nleft = 0\ncnt = 0\nright = len(c) - 1\nwhile left < n and right >=0 and left < right:\n\twhile left < n and c[left] != 'W':\n\t\tleft += 1\n\twhile right >= 0 and c[right] != 'R':\n\t\tright -= 1\n\tif left< n and right >= 0 and left<right:\n\t\tc[left], c[right] = c[right], c[left]\n\t\tcnt += 1\n\t\tleft += 1\n\t\tright -=1 \nprint(cnt)\n\n", "n = int(input())\nc = list(input())\nleft = 0\ncnt = 0\nright = len(c) - 1\nwhile left < n and right >=0 and left < right:\n while left < n and c[left] != 'W':\n left += 1\n while right >= 0 and c[right] != 'R':\n right -= 1\n if left< n and right >= 0 and left<right:\n c[left], c[right] = c[right], c[left]\n cnt += 1\n left += 1\n right -=1 \nprint(cnt)\n\n"]
['Runtime Error', 'Accepted']
['s872118252', 's900780982']
[9340.0, 10756.0]
[28.0, 92.0]
[367, 394]
p02597
u975997984
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["C = list(input())\nC_ = sorted(C)\n\nwr = rw = 0\nfor i in range(len(C_)):\n if C[i] != C_[i]:\n if C[i] == 'R' and C_[i] == 'W':\n rw += 1\n else:\n wr += 1\n\nprint(max(wr, rw))\n", "N = int(input())\nC = list(input())\nC_ = sorted(C)\n\nwr = rw = 0\nfor i in range(len(C_)):\n if C[i] != C_[i]:\n if C[i] == 'R' and C_[i] == 'W':\n rw += 1\n else:\n wr += 1\n\nprint(max(wr, rw))\n"]
['Wrong Answer', 'Accepted']
['s694333776', 's736178555']
[8992.0, 12700.0]
[30.0, 78.0]
[208, 225]
p02597
u981418135
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
['n = int(input())\nc = input()\nna = len(c)\nred = 0\nwhi = 0\n\ncou_start = 0\ncou = 0\nfor i in reversed(range(0,na)):\n if c[i] == "W":\n whi += 1\n if cou_start == 1:\n cou += 1\n else:\n red += 1\n \n #print(red,whi,cou)\n \n if red >= 2 and whi >= 1:\n cou_start=1\n \n\npri = min(whi,red)\nif cou != 0:\n\tpri = min(cou,pri)\n \nprint(pri)', 'n = int(input())\nc = list(input())\n\ncour = c.count("R")\ncount = 0\n\nfor i in range(cour):\n if c[i] == "W":\n count += 1\n\nprint(count)']
['Wrong Answer', 'Accepted']
['s503738034', 's498284694']
[9496.0, 10604.0]
[84.0, 48.0]
[387, 141]
p02597
u998741086
2,000
1,048,576
An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white. You can do the following two kinds of operations any number of times in any order: * Choose two stones (not necessarily adjacent) and swap them. * Choose one stone and change its color (from red to white and vice versa). According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?
["#!/usr/bin/env python3\nimport time\n\nk = int(input())\ns = ''\n\nrs = []\n\nstart = time.time()\ncnt = 0 \nwhile True:\n cnt += 1\n s += '7' \n n = int(s)\n r = n%k \n if r==0:\n print(cnt)\n exit()\n\n if r in rs: \n print(-1)\n end = time.time()\n exit()\n\n rs.append(r)\n end = time.time()\n t = end-start \n if t >= 1.8:\n print(k-1)\n exit()\n", "#!/usr/bin/env python3\n\nn = int(input())\ngiven_s = input()\ns = list(given_s)\n\nnr = nw = 0 \nnr = s.count('R')\nnw = n-nr\nans = 0 \n\nif nw == 0:\n print(ans)\n exit()\n\nl = s[:nr]\nans = l.count('W')\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s417161395', 's172900511']
[9456.0, 12024.0]
[1829.0, 42.0]
[400, 209]
p02598
u017415492
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\nn,k=map(int,input().split())\na=list(map(int,input().split()))\n\nx0, x1 = 0, 10**9\nwhile x0 + 1 < x1:\n x = (x0+x1)//2\n suma=0\n for i in a:\n suma += (a//x)\n \n if suma > k:\n x0 = x\n else:\n x1 = x\nprint(x1)', 'import math\nn,k=map(int,input().split())\na=list(map(int,input().split()))\n\nx0, x1 = 0, 10**9\nwhile x0 + 1 < x1:\n x = (x0+x1)//2\n suma=0\n for i in a:\n if i%x==0:\n suma+=(i//x)-1\n else:\n suma += (i//x)\n \n if suma > k:\n x0 = x\n else:\n x1 = x\nprint(x1)\n']
['Runtime Error', 'Accepted']
['s405945997', 's847226089']
[30916.0, 31232.0]
[71.0, 1036.0]
[231, 280]
p02598
u019685451
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from math import ceil\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\ndef check(l):\n cnt = sum(ceil(a / l) - 1 for a in A)\n return cnt <= K\n\nlb, ub = 0, max(A)\nfor _ in range(100):\n mid = (lb + ub) / 2\n if check(mid):\n ub = mid\n else:\n lb = mid\nprint(round(lb))', 'from math import ceil\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\ndef check(l):\n cnt = sum(ceil(a / l) - 1 for a in A)\n return cnt <= K\n\nlb, ub = 0, max(A)\nfor _ in range(50):\n mid = (lb + ub) / 2\n if check(mid):\n ub = mid\n else:\n lb = mid\nprint(ceil(ub))']
['Wrong Answer', 'Accepted']
['s839839858', 's558215275']
[31104.0, 31156.0]
[2206.0, 1429.0]
[314, 312]
p02598
u022979415
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["from math import ceil, floor\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort()\n lower = 1\n upper = 10 ** 9 + 7\n while upper - lower >= 1:\n target = (lower + upper) / 2\n now = 0\n for i in range(n):\n now += ceil(a[i] / target) - 1\n if now > k:\n lower = target\n else:\n upper = target\n print(floor(lower) if k > 0 else a[-1])\n\n\nif __name__ == '__main__':\n main()\n\n", "from math import ceil\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort()\n ng = 0\n ok = a[-1]\n while ok - ng > 1:\n mid = (ok + ng) // 2\n cnt = 0\n for i in range(n):\n cnt += (a[i] - 1) // mid\n if cnt <= k:\n ok = mid\n else:\n ng = mid\n print(ceil(ok) if k > 0 else a[-1])\n\n\nif __name__ == '__main__':\n main()\n\n"]
['Wrong Answer', 'Accepted']
['s160489860', 's648959122']
[31032.0, 31056.0]
[1168.0, 756.0]
[497, 442]
p02598
u065079240
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math \nN,K=map(int,input().split())\nA=[int(x) for x in input().split()]\nA=sorted(A)\nleft=0\nright=max(A)\nmid=max((left+right)//2,1)\n\nwhile(right-left>=1):\n numofcut=0\n mid=(left+right)//2\n for i in range(N):\n if A[i]%mid==0:\n numofcut+=A[i]//mid -1\n else:\n numofcut+=A[i]//mid\n #print(numofcut)\n if numofcut>K:\n left=mid+1\n else:\n right=mid\n max((left+right)//2,1)\n\nprint(mid)', 'import math \nN,K=map(int,input().split())\nA=[int(x) for x in input().split()]\nA=sorted(A)\nleft=0\nright=max(A)\nmid=max((left+right)//2,1)\n\nwhile(right-left>=1):\n numofcut=0\n \n for i in range(N):\n numofcut+=math.ceil(A[i]/mid)\n #print(numofcut)\n if numofcut>K:\n left=mid+1\n else:\n right=mid\n mid=max((left+right)//2,1)\n if mid==1:\n break\nprint(mid)', 'import math \nimport bisect\nN,K=map(int,input().split())\nA=[int(x) for x in input().split()]\nA=sorted(A)\nleft=0\nright=max(A)\nmid=N//2\nwhile(right-left>=0):\n numofcut=0\n mid=(left+right)//2\n for i in range(N):\n if A[i]%mid==0:\n numofcut+=A[i]//mid -1\n else:\n numofcut+=A[i]//mid\n #print(numofcut)\n if numofcut>K:\n left=mid+1\n else:\n right=mid-1\n \n\nprint(mid)', 'import math \nimport bisect\nN,K=map(int,input().split())\nA=[int(x) for x in input().split()]\nA=sorted(A)\nleft=0\nright=max(A)\nmid=N//2\nwhile(right-left>=1):\n numofcut=0\n mid=(left+right)//2\n for i in range(N):\n if A[i]%mid==0:\n numofcut+=A[i]//mid -1\n else:\n numofcut+=A[i]//mid\n #print(numofcut)\n if numofcut>K:\n left=mid+1\n else:\n right=mid\n \n\nprint(mid)', 'import math \nN,K=map(int,input().split())\nA=[int(x) for x in input().split()]\nA=sorted(A)\nleft=0\nright=max(A)\nmid=max((left+right)//2,1)\n\nwhile(right-left>=1):\n numofcut=0\n \n for i in range(N):\n numofcut+=math.ceil(A[i]/mid)-1\n #print(numofcut)\n if numofcut>K:\n left=mid+1\n else:\n right=mid\n mid=max((left+right)//2,1)\n if mid==1:\n break\nprint(mid)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s052693275', 's292746929', 's594315722', 's969660161', 's680090824']
[30928.0, 31152.0, 31044.0, 31044.0, 30988.0]
[1980.0, 1603.0, 1853.0, 1641.0, 1631.0]
[452, 398, 427, 425, 400]
p02598
u067937922
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['\nimport sys\n\n\ndef main():\n """Main program."""\n log_count, cut_count = (int(i) for i in sys.stdin.readline().split())\n logs = [int(i) for i in sys.stdin.readline().split()]\n high = max(logs)\n low = 1\n soln = high\n # Binary search for the answer.\n while low < high:\n mid = (low + high) // 2\n cuts_needed = 0\n if mid:\n cuts_needed = sum(log // mid for log in logs)\n if cuts_needed <= cut_count:\n soln = min(soln, mid)\n high = mid - 1\n else:\n low = mid + 1\n print(soln)\n\n\nif __name__ == \'__main__\':\n main()\n', '\nimport sys\nfrom math import ceil\n\n\ndef main():\n """Main program."""\n log_count, cut_count = (int(i) for i in sys.stdin.readline().split())\n logs = [int(i) for i in sys.stdin.readline().split()]\n high = max(logs)\n low = 1\n soln = high\n # Binary search for the answer.\n while low <= high:\n mid = (low + high) // 2\n cuts_needed = sum([int(ceil(log / mid)) - 1 for log in logs])\n if cuts_needed <= cut_count:\n soln = min(soln, mid)\n high = mid - 1\n else:\n low = mid + 1\n print(soln)\n\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Accepted']
['s309953319', 's864074048']
[30944.0, 31000.0]
[376.0, 1143.0]
[710, 705]
p02598
u072717685
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom math import ceil\nfrom heapq import heapify,heappop,heappush\ndef main():\n n, k, *a = map(int, read().split())\n minusa = [-ae for ae in a]\n\n heapify(minusa)\n while k > 0:\n maxa = heappop(minusa)\n heappush(minusa, maxa/2)\n k -= 1\n print(minusa)\n r = heappop(minusa)\n r *= -1\n r = ceil(r)\n print(r)\n\nif __name__ == '__main__':\n main()\n", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\n\nfrom math import ceil\ndef main():\n n, k = map(int, input().split())\n a = tuple(map(int, input().split()))\n\n def kaisu(long):\n return(sum([ceil(ae/long) - 1 for ae in a]))\n\n def bs_meguru(key):\n def isOK(index, key):\n if kaisu(index) <= key:\n return True\n else:\n return False\n ng = 0\n ok = max(a)\n while abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if isOK(mid, key):\n ok = mid\n else:\n ng = mid\n return ok\n print(bs_meguru(k))\n\nif __name__ == '__main__':\n main()\n\n"]
['Runtime Error', 'Accepted']
['s841577138', 's462113572']
[158220.0, 31108.0]
[2370.0, 837.0]
[456, 700]
p02598
u078982327
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n, k = map(int, input().split())\nA = list(map(int, input().strip().split()))\n\nb = 0\ne = max(A)\nL = e // 2\nwhile e - b >= 1:\n m = sum(list(map(lambda x: x // L, A)))\n if m <= k:\n e = L\n L = (e + b) // 2\n else:\n b = L\n L = (e + b) // 2\nprint(e)\n', 'n, k = map(int, input().split())\nA = list(map(int, input().strip().split()))\n\nb = 0\ne = max(A)\nL = e // 2\nwhile e - b > 1:\n L = (e + b) // 2\n m = sum(list(map(lambda x: (x - 1) // L, A)))\n if m <= k:\n e = L\n else:\n b = L\nprint(e)\n']
['Runtime Error', 'Accepted']
['s780031985', 's859642820']
[30548.0, 30800.0]
[2206.0, 674.0]
[280, 256]
p02598
u085717502
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['#!/usr/bin/env python\n# coding: utf-8\n\n# In[16]:\n\n\nN,K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\n# In[23]:\n\n\nmax(A)\ncnt\n\n\n# In[41]:\n\n\ncnt = 0\nlow = 0\nhigh = max(A)\nans = max(A)\nold = int(high)\nmycount = 0\nwhile low < high:\n mid = (high+low)/2\n cnt = sum([(x-0.001)//mid for x in A])\n if cnt <= K:\n high = mid\n ans = min(ans, int(-(-mid//1)))\n else:\n low = mid\n if int(mid) == old:\n mycount += 1\n if mycount == 100:\n break\n old = int(mid)\nprint(ans)\n\n\n# In[ ]:\n\n\n\n\n', '#!/usr/bin/env python\n# coding: utf-8\n\n# In[16]:\n\n\nN,K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\n# In[49]:\n\n\nlow = 0\nhigh = max(A)\ndef ok(x):\n cnt = 0\n for a in A:\n cnt += (a//x)\n if a%x == 0:\n cnt -= 1\n return cnt <= K\n \nwhile high-low > 1:\n mid = (high+low)//2\n if ok(mid):\n high = mid\n else:\n low = mid\nprint(high)\n\n\n# In[ ]:\n\n\n\n\n']
['Runtime Error', 'Accepted']
['s449742254', 's016105768']
[30992.0, 30888.0]
[73.0, 616.0]
[544, 414]
p02598
u094102716
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k=map(int,input().split())\nA = list(map(int, input().split()))\nr = max(A)\nl = 0\nwhile l+1<r:\n mid=(l+r)//2\n if sum([a-1]//mid for a in A)>k:\n l=mid\n else:\n r = mid\nprint(r)\n', 'n,k=map(int,input().split())\nA = list(map(int, input().split()))\nr = max(A)\nl = 0\nwhile l+1<r:\n mid=(l+r)//2\n if sum([(a-1)//mid for a in A])>k:\n l=mid\n else:\n r = mid\nprint(r)']
['Runtime Error', 'Accepted']
['s509530157', 's699626203']
[30644.0, 30708.0]
[71.0, 563.0]
[184, 185]
p02598
u123579949
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import numpy as np\nN,K = map(int, input().split()) \nLogs = np.array([int(x) for x in input().split()])\ncut = [1]*N\nchip = Logs.copy()\nfor i in range(K):\n x = np.argmax(chip)\n cut[x]+=1\n chip[x]= Logs[x]/cut[x]\n\nprint(int(max(chip)))', 'import numpy as np\nN,K = map(int, input().split()) \nLogs = np.array([int(x) for x in input().split()])\ncut = [1]*N\nchip = Logs\nfor i in range(K):\n x = np.argmax(Logs)\n cut[x]+=1\n chip[x]= Logs[x]/cut[x]\nprint(int(max(chip)))\n\n', 'import numpy as np\nimport math\nN,K = map(int, input().split()) \nLogs = np.array([int(x) for x in input().split()])\nave = sum(Logs)/(N+K)\ncut = np.array([max(1,int(x/ave)) for x in Logs])\nchip = Logs/cut\nchip=np.sort(chip)[::-1]\nprint(math.ceil(chip[N+K-sum(cut)]))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s701619578', 's747274719', 's108921571']
[48700.0, 49372.0, 49464.0]
[2206.0, 2206.0, 698.0]
[235, 229, 264]
p02598
u131881594
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nif k==0:\n print(max(a))\n exit()\na.sort()\nleft,right=0,a[n-1]\nmid=right\nwhile abs(right-left)>1:\n mid=(left+right)//2\n temp=0\n for i in range(n-1,-1,-1):\n if a[i]<=mid: break\n temp+=a[i]//mid\n if temp>k: left=mid\n else: right=mid\nprint(mid)', '\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nif k==0:\n print(max(a))\n exit()\na.sort()\nleft,right=0,a[n-1]\nmid=right\nwhile abs(right-left)>2:\n mid=(left+right)//2\n temp=0\n for i in range(n-1,-1,-1):\n if a[i]<=mid: break\n temp+=a[i]//mid\n if temp>k: left=mid\n else: right=mid\nmid-=1\nif mid<=0: mid=1\nwhile True:\n temp=0\n flag=0\n for i in range(n-1,-1,-1):\n if a[i]<=mid: break\n temp+=a[i]//mid\n if temp>k: mid+=1\n else:\n flag=1\n break\n if flag: break\nprint(mid)']
['Wrong Answer', 'Accepted']
['s476967514', 's922648088']
[30776.0, 30852.0]
[1370.0, 1926.0]
[337, 558]
p02598
u133936772
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['f=lambda:[*map(int,input().split())]\nn,k=f()\na=f()\na=[i*100 for i in a]\n# Binary Search\ndef ok(x):\n c=0\n for i in a:\n c+=0--i//x\n return c<=n+k\nl,r=0,10**11+1\nwhile r-l>1:\n m=l+r>>1\n if ok(m): r=m\n else: l=m\nprint(l,r)\nt=0--r//100\nprint(t-ok(t-1) if t>1 else t)', 'n,k,*a=map(int,open(0).read().split())\nl,r=0,10**9\nwhile r-l>1:\n m=l+r>>1\n if sum(0--i//m for i in a)>n+k: l=m\n else: r=m\nprint(r)']
['Wrong Answer', 'Accepted']
['s808357055', 's174169537']
[30844.0, 31752.0]
[1365.0, 642.0]
[278, 133]
p02598
u135389999
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n, k = map(int, input().split())\na = list(map(int, input().split()))\n \nfloor = 1\nceil = max(a)\nL = (ceil + floor)//2\n \n \ndef cut(long, logs):\n cnt = 0\n for i in logs:\n cnt += (i / long) - 1\n if i % long != 0:\n cnt += 1\n return cnt\n \n \nwhile ceil - floor > 1:\n L = (ceil + floor)//2\n num = cut(L, a)\n if num > k:\n floor = L\n else:\n ceil = L\n \nprint(ceil)', 'import math\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nfloor = 0\nceil = max(a)\n\n\ndef cut(long, logs):\n cnt = 0\n for i in logs:\n cnt += math.ceil(i / long) - 1\n return cnt\n\n\nwhile ceil - floor > 1:\n L = (ceil + floor)//2\n num = cut(L, a)\n if num <= k:\n ceil = L\n else:\n floor = L\n\nprint(ceil)']
['Wrong Answer', 'Accepted']
['s403381368', 's169300657']
[30892.0, 31020.0]
[819.0, 946.0]
[413, 361]
p02598
u137061893
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nlow = 0\nhigh = max(a)\n\nwhile low + 1 < high:\n print(low, high)\n mid = (low + high) // 2\n m = 0\n for x in a:\n m += (x - 1) // mid\n \n if m <= k:\n high = mid\n else:\n low = mid\n\nprint(high)', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nlow = 0\nhigh = max(a)\n\nwhile low + 1 < high:\n mid = (low + high) // 2\n m = 0\n for x in a:\n m += (x - 1) // mid\n \n if m <= k:\n high = mid\n else:\n low = mid\n\nprint(high)']
['Wrong Answer', 'Accepted']
['s351369602', 's700086182']
[30796.0, 30872.0]
[813.0, 936.0]
[297, 276]
p02598
u151785909
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\n\nn , k = map(int, input().split())\na = list(map(int,input().split()))\na.sort()\n\nleft=a[0]\nright=a[n-1]\nmid = (left+right)/2\nwhile right - left > 1:\n times = 0\n for i in range(n):\n times+=math.ceil(a[i]/mid)-1\n if times<=k:\n right=mid\n mid=(left+right)/2\n else:\n left = mid\n mid =(left+right)/2\n\nprint(math.ceil(mid))\n', 'import math\n\nn , k = map(int, input().split())\na = list(map(int,input().split()))\n\nleft=0\nright=max(a)\nmid = (left+right)/2\nwhile right - left > 0.5:\n times = 0\n for i in range(n):\n times+=math.ceil(a[i]/mid)-1\n if times<=k:\n right=mid\n mid=(left+right)/2\n else:\n left = mid\n mid =(left+right)/2\n\nprint(math.ceil(mid))\n']
['Wrong Answer', 'Accepted']
['s467687404', 's167093546']
[31072.0, 31080.0]
[1933.0, 1613.0]
[376, 366]
p02598
u180172332
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\nn,k = map(int,input().split())\na_list = list(map(int,input().split()))\n\nmin_num = 1\nmax_num = 10**9+1\nwhile True:\n print(min_num)\n x = int((min_num+max_num)/2)\n if sum([math.ceil(a/x)-1 for a in a_list])>k:\n min_num = x\n else:\n max_num = x\n if max_num-min_num<=1:\n break\n #print(x)\nif sum([math.ceil(a/min_num)-1 for a in a_list])>k:\n print(min_num+1)\nelse:\n print(min_num)', 'import math\nn,k = map(int,input().split())\na_list = list(map(int,input().split()))\n\nmin_num = 1\nmax_num = 10**9+1\nwhile True:\n print(min_num)\n x = int((min_num+max_num)/2)\n if sum([math.ceil(a/x)-1 for a in a_list])>k:\n min_num = x\n else:\n max_num = x\n if max_num-min_num<=1:\n break\n #print(x)\nif sum([math.ceil(a/min_num)-1 for a in a_list])>k:\n print(int(min_num)+1)\nelse:\n print(int(min_num))', 'import math\nn,k = map(int,input().split())\na_list = list(map(int,input().split()))\n\nmin_num = 1\nmax_num = 10**9+1\nwhile True:\n #print(min_num)\n x = int((min_num+max_num)/2)\n if sum([math.ceil(a/x)-1 for a in a_list])>k:\n min_num = x\n else:\n max_num = x\n if max_num-min_num<=1:\n break\n #print(x)\nif sum([math.ceil(a/min_num)-1 for a in a_list])>k:\n print(min_num+1)\nelse:\n print(min_num)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s863848174', 's940555103', 's228855918']
[31088.0, 31104.0, 30940.0]
[1047.0, 1107.0, 1117.0]
[430, 440, 431]
p02598
u202560873
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["import numpy as np\n\nN, K = [int(x) for x in input().split()]\nA = np.array([int(x) for x in input().split()])\n\nL = np.max(A)\n\nans = L\nlow = 1\nhigh = L\nwhile 1:\n print(str(low) + ' ' + str(high))\n if low == high:\n ans = low\n break\n mid = (low + high) // 2\n if np.sum(A // mid) <= K:\n high = mid\n else:\n low = mid + 1\n\nprint(ans)", 'import numpy as np\n\nN, K = [int(x) for x in input().split()]\nA = np.array([int(x) for x in input().split()])\nI = np.array([1] * N)\n\nL = np.max(A)\n\nans = L\nlow = 1\nhigh = L\nwhile 1:\n if low == high:\n ans = low\n break\n \n mid = (low + high) // 2\n if np.sum((A - I) // mid) <= K:\n high = mid\n else:\n low = mid + 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s533176594', 's938538625']
[49432.0, 49300.0]
[225.0, 241.0]
[369, 364]
p02598
u211706121
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from math import ceil\n\nm=1\nM=10**9\n\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef OK(k):\n if sum([ceil(a/k) for a in A])<=K:\n return True\n else:\n return False\n\nwhile M-m>1:\n p=(m+M)//2\n if OK(p):\n m=p\n else:\n M=p\nprint(m)', 'from math import floor\n\nm=0\nM=10**9+1\n\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef OK(p):\n if sum([(a-1)//p for a in A])<=K:\n return True\n else:\n return False\n\nwhile M-m>1:\n p=(m+M)//2\n if OK(p):\n M=p\n else:\n m=p\nprint(M)']
['Wrong Answer', 'Accepted']
['s309735963', 's062225120']
[31044.0, 31108.0]
[735.0, 527.0]
[285, 287]
p02598
u226849101
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\n\nN,K = map(int,input().split())\n\na = list(map(int, input().split()))\nl = 0\nr = max(a)\n\nx = (l+r)//2\nans = r+1\nwhile(r>1+l):\n print(str(l)+":"+str(r))\n x = (l+r)//2\n count = 0\n for i in range(N):\n count += math.ceil(a[i] /x)-1\n if (count <=K):\n if (ans > x):\n ans = x\n r = x\n else:\n l = x\n\nfor i in range(N):\n count += math.ceil(a[i]/l)-1\n\nif (count <=K):\n ans = l\nelse:\n ans = r\nprint(ans)\n\n \n \n\n \n', 'import math\n\nN,K = map(int,input().split())\n\na = list(map(int, input().split()))\nl = 0\nr = max(a)\n\nx = (l+r)//2\nans = r+1\nwhile(r>1+l):\n\n \n x = (l+r)//2\n if x == 0:\n break\n\n count = 0\n for i in range(N):\n count += math.ceil(a[i] /x)-1\n if (count <=K):\n if (ans > x):\n ans = x\n r = x\n else:\n l = x\ncount = 0\nans = x\nif(x!= 0 and l != 0):\n \n for i in range(N):\n count += math.ceil(a[i]/l)-1\n\n if (count <=K):\n ans = l\n else:\n ans = r\n\nif l==0:\n ans = r\nprint(ans)\n\n \n \n\n \n']
['Runtime Error', 'Accepted']
['s785368736', 's650128473']
[31028.0, 31152.0]
[1531.0, 1520.0]
[493, 594]
p02598
u231095456
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from math import ceil\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\ndef chk(L):\n cnt = 0\n for i in range(N):\n cnt += ceil(A[i]/L)-1\n return cnt <= K\nl, r = 1, max(A)\nwhile l <= r:\n m = (l+r)//2\n if chk(m):\n r = m-1\n else:\n l = m+1\nprint(max([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))', 'from math import ceil\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\ndef chk(L):\n cnt = 0\n for i in range(N):\n cnt += ceil(A[i]/L)-1\n return cnt <= K\nl, r = 1, max(A)\nwhile l <= r:\n m = (l+r)//2\n if chk(m):\n r = m-1\n else:\n l = m+1\nprint(max([x for x in [l-1, l, l+1, r-1,r,r+1, m-1,m,m+1] if chk(x)]))', 'from math import ceil\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\ndef chk(L):\n cnt = 0\n for i in range(N):\n cnt += ceil(A[i]/L)-1\n return cnt <= K\nl, r = 1, max(A)\nwhile l <= r:\n m = (l+r)//2\n if chk(m):\n r = m-1\n else:\n l = m+1\nprint(max([x for x in [m-1,m,m+1] if chk(x)]))', 'from math import ceil\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\ndef chk(L):\n cnt = 0\n for i in range(N):\n cnt += ceil(A[i]/L)-1\n return cnt <= K\nl, r = 1, max(A)\nwhile l <= r:\n m = (l+r)//2\n if chk(m):\n r = m-1\n else:\n l = m+1\nprint(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s002187724', 's670891138', 's968034104', 's963013453']
[30952.0, 32016.0, 31160.0, 31000.0]
[1209.0, 1262.0, 1088.0, 1075.0]
[347, 361, 337, 347]
p02598
u231570044
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["import numpy as np\nfrom numba import jit\nverbose = False\n\nN, K = list(map(int, input().split()))\nA = np.array(list(map(int, input().split())), dtype=np.int64)\n\nul = np.ceil(np.sum(A)/(K))\nll= np.floor(np.max(A)/(K+1))\n\nEPS = 1 / 10**6\n\n@jit(nopython=True)\ndef cut(A, c, N):\n return (np.sum(np.ceil(A/c))-N)\n\nc = np.ceil((ul+ll)/2)\nmx = np.max(A)\nwhile True:\n if ul-ll == 1:\n break\n nk = cut(A, c, N)\n if verbose:\n print('c:', c, 'nk:', nk, 'ul - ll:', ul, '/', ll)\n prev = c\n if nk >K: # more cuts than target; larger logs can be made\n ll = c\n c = np.floor(ul + c)/2)\n else: #i.e. nk < K, less cuts than target\n ul = c\n c = np.ceil((c + ll)/2)\n \nif cut(A, ll+EPS, N) >= K:\n print(np.min((np.max(A), int(ul))))\nelse:\n print(int(ll))\n \n", "import numpy as np\nfrom numba import jit\nimport random\nverbose = False\nrand = False\n\nif rand:\n N, K = random.choice(range(10)), random.choice(range(10))\n A = np.array(random.choices(range(10**9), k=N))\nelse:\n N, K = list(map(int, input().split()))\n A = np.array(list(map(int, input().split())), dtype=np.int64)\n\nul = np.ceil(np.sum(A)/(K+1))\nll= np.floor(np.max(A)/(K+1))\n\nEPS = 1 / 10**6\n\n@jit(nopython=True)\ndef cut(A, c, N):\n return (np.sum(np.ceil(A/c))-N)\n\nc = np.ceil((ul+ll)/2)\nmx = np.max(A)\nwhile True:\n if ul-ll <= 1:\n break\n nk = cut(A, c, N)\n if verbose:\n print('c:', c, 'nk:', nk, 'ul - ll:', ul, '/', ll)\n prev = c\n if nk >K: # more cuts than target; larger logs can be made\n ll = c\n c = np.floor((ul + c)/2)\n else: #i.e. nk < K, less cuts than target\n ul = c\n c = np.ceil((c + ll)/2)\n \nif cut(A, ll+EPS, N) >= K:\n print(np.min((np.max(A), int(ul))))\nelse:\n print(int(ll))\n \n"]
['Runtime Error', 'Accepted']
['s764363298', 's606548338']
[9044.0, 115384.0]
[29.0, 740.0]
[814, 981]
p02598
u259543319
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['N, M = input().strip().split()\nn, k = [int(N), int(M)]\na = list(map(int, input().strip().split()))\nle = 0\nri = 10000000000\nwhile ri - le > 1:\n mid = (le + ri) \n num = 0\n for i in a:\n num += (i-1) \n if num <= k:\n ri = mid\n else:\n le = mid\nprint(ri)\n', 'N, M = input().strip().split()\nn, k = [int(N), int(M)]\na = list(map(int, input().strip().split()))\nle = 0\nri = 10000000000\nwhile ri - le > 1:\n mid = (le + ri)// 2\n num = 0\n for i in a:\n num += (i-1)// mid\n if num <= k:\n ri = mid\n else:\n le = mid\nprint(ri)\n']
['Wrong Answer', 'Accepted']
['s696006999', 's335004382']
[30872.0, 30772.0]
[2205.0, 916.0]
[284, 292]
p02598
u266014018
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["def main():\n import sys\n def input(): return sys.stdin.readline().rstrip()\n n , k = map(int, input().split())\n a = list(map(int, input().split()))\n l = 0\n r = max(a)\n while l < r:\n m = (l+r)//2\n cnt = 0\n for x in a:\n cnt += (x-1)//m\n if cnt > k: l = m\n else: r = m-1\n print(m)\n\n \n\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n def input(): return sys.stdin.readline().rstrip()\n n , k = map(int, input().split())\n a = list(map(int, input().split()))\n from heapq import heappop, heappush, heapreplace\n a = [-x for x in a]\n a.sort()\n for i in range(k):\n x = a[0]\n if abs(x) < 1:\n break\n heapreplace(a, x//3)\n heappush(a, x-x//2)\n ans = abs(a[0])\n print(ans)\n \n\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n def input(): return sys.stdin.readline().rstrip()\n n , k = map(int, input().split())\n a = list(map(int, input().split()))\n \n def check(m):\n cnt = 0\n for x in a:\n cnt += (x-1)//m\n return cnt <= k\n \n l, r = 0, max(a)\n while r-l > 1:\n m = (r+l)//2\n if check(m): r = m\n else: l = m\n print(r)\n\n \n\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s316244853', 's583412006', 's586023013']
[30944.0, 147624.0, 30832.0]
[2206.0, 2212.0, 492.0]
[392, 466, 445]
p02598
u284120954
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["import math\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n A = sorted(A, reverse=True)\n tA = []\n for a in A:\n tA.append((a, 1))\n\n for k in range(K):\n print('rope:' + str(k))\n a, diva = tA[1]\n b, divb = tA[0]\n print(tA)\n while b/divb > a/diva:\n divb += 1\n B = b/divb\n x = 1\n while x < N:\n xn, divx = tA[x]\n if xn/divx < B:\n break\n x += 1\n if x != N:\n tA.insert(x, (b, divb))\n else:\n tA.append((b, divb))\n tA = tA[1:]\n print(tA)\n print(math.ceil(tA[0][0]/tA[0][1]))\n\n\nif __name__ == '__main__':\n main()\n\n", "from math import ceil\n\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n def check(Min):\n kill = 0\n for a in A:\n kill += (ceil(a/Min)-1)\n return kill <= K\n\n l = 0\n r = 1000000000\n\n while r-l > 1:\n mid = (l+r)//2\n if check(mid):\n r = mid\n else:\n l = mid\n print(r)\n \n\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s832727675', 's317301007']
[127340.0, 30908.0]
[2340.0, 819.0]
[736, 443]
p02598
u288430479
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k = map(int,input().split())\nA = list(map(int,input().split()))\nng = 0\nok = max(A)\n\ndef queri(n):\n count = 0\n for i in A:\n count += -(-i//n)\n if k>= count:\n return True\n else:\n return False\n\nwhile ok - ng > 1:\n mid = (ok+ng)//2\n if queri(mid) :\n ok = mid\n else:\n ng = mid\nprint(ok)', 'n,k = map(int,input().split())\nA = list(map(int,input().split()))\nng = 0\nok = max(A)\n\ndef queri(n):\n count = 0\n for i in A:\n count += -(-i//n)-1\n if k>= count:\n return True\n else:\n return False\n\nwhile ok - ng > 1:\n mid = (ok+ng)//2\n if queri(mid) :\n ok = mid\n else:\n ng = mid\nprint(ok)']
['Wrong Answer', 'Accepted']
['s695226200', 's646143758']
[30824.0, 30792.0]
[566.0, 665.0]
[339, 341]
p02598
u312514694
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['mport math\ndef check(lis,k,mid):\n\tfor i in lis:\n\t\tk-=(i//mid)\n\treturn k>=0\nn,k=map(int,input().split())\nlis=list(map(int,input().split()))\na,b=1,max(lis)\nans=b\nwhile(a<=b):\n\tmid=(a+b)/2\n\tif(check(lis,k,mid)):\n\t\tans=mid\n\t\tb=mid-0.000001\n\telse:\n\t\ta=mid+0.000001\nprint(int(math.ceil(ans)))', 'def check(lis,k,mid):\n\tfor i in lis:\n\t\tk-=(i//mid)\n\treturn k>=0\nn,k=map(int,input().split())\nlis=list(map(int,input().split()))\na,b=min(lis),max(lis)\nans=b\nwhile(a<=b):\n\tmid=(a+b)//2\n\tif(check(lis,k,mid)):\n\t\tans=mid\n\t\tb=mid-1\n\telse:\n\t\ta=mid+1\nprint(ans)\n\n', 'def check(lis,k,mid):\n\tfor i in lis:\n\t\tif(i%mid==0):\n\t\t\tk+=1\n\t\tk-=(i//mid)\n\treturn k>=0\nn,k=map(int,input().split())\nlis=list(map(int,input().split()))\na,b=1,max(lis)\nans=b\nwhile(a<=b):\n\tmid=(a+b)//2\n\tif(check(lis,k,mid)):\n\t\tans=mid\n\t\tb=mid-1\n\telse:\n\t\ta=mid+1\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s308542179', 's429559838', 's265799568']
[8836.0, 30812.0, 30828.0]
[25.0, 387.0, 630.0]
[286, 255, 271]
p02598
u317423698
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["import sys\n\n\ndef resolve(in_):\n n = int(next(in_))\n c = next(in_).strip()\n\n ans = 0\n left = 0\n right = len(c) - 1\n while left < right:\n if c[left] == 'R':\n left += 1\n continue\n if c[right] == 'W':\n right -= 1\n continue\n left += 1\n right -= 1\n ans += 1\n\n return ans\n\n\ndef main():\n answer = resolve(sys.stdin)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom math import ceil, floor\n\ndef cut_logs(x, a):\n return sum(ceil(ai / x) - 1 for ai in a)\n\n\ndef resolve(in_):\n n, k = map(int, next(in_).split())\n logs = tuple(map(int, next(in_).split())) # A\n assert n == len(logs)\n max_logs = max(logs)\n\n lb = 0\n ub = max_logs\n while ub - lb > 1:\n mid = (ub + lb) // 2\n v = cut_logs(mid, logs)\n # print(f'{lb=} {mid=} {ub=} {v<=k=} {v=} {k=}')\n if v <= k:\n ub = mid\n else:\n lb = mid\n # print(f'end: {lb=} {mid=} {ub=} {v<=k=} {v=} {k=}')\n\n return ub\n\n\ndef main():\n answer = resolve(sys.stdin.buffer)\n print(answer)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s377204198', 's058226205']
[9192.0, 29368.0]
[20.0, 795.0]
[469, 697]
p02598
u319589470
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\n\n\n\n\nn,k = MI()\na = LI()\n\ndef cutting_isOK(x,li,k):\n ans = 0\n for i in range(n):\n ans += math.ceil(li[i]/x) - 1\n if ans <= k:\n return True\n else:\n return False\nleft = -1\nright = 10**9+1\nwhile right != left + 1:\n mid = (left+right)//2\n if cutting_isOK(mid,a,k):\n right = mid\n else:\n left = mid\nprint(right)\n\n', '\nimport math\n\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\ndef MI(): return map(int,input().split())\ndef LLI(n): return [list(map(int, input().split())) for _ in range(n)]\n\n\n\n\n\n\n\n\nn,k = MI()\na = LI()\n\ndef cutting_isOK(x,li,k):\n ans = 0\n for i in range(n):\n ans += math.ceil(li[i]/x) - 1\n if ans <= k:\n return True\n else:\n return False\nleft = 0\nright = 10**9+1\nwhile abs(left-right) > 1:\n mid = (left+right)//2\n if cutting_isOK(mid,a,k):\n right = mid\n else:\n left = mid\nprint(right)\n']
['Runtime Error', 'Accepted']
['s932228357', 's412247194']
[30768.0, 31020.0]
[72.0, 1147.0]
[1085, 1098]
p02598
u342651068
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\n\ndef is_ok(A, x, K):\n cut_count = 0\n for number in A:\n cut_count += (math.ceil(number / x)) - 1\n return cut_count <= K\n\nA = []\n# N = int(input())\n# K = int(input())\nans = 0\n\nl = 0\nr = 10 ** 9\n\n# for _ in range(N):\n# A.append(int(input()))\n\nN = 10\nK = 10\nA = [158260522,877914575,602436426,24979445,861648772,623690081,433933447,476190629,262703497,211047202]\n\nwhile r - l > 1:\n print("r = " + str(r) + ", l = " + str(l))\n x = (r + l) // 2\n if is_ok(A, x, K):\n r = x \n else:\n l = x\n \nprint(r)', 'def is_ok(A, x, K):\n cut_count = 0\n for number in A:\n cut_count += (number // x) - 1\n return cut_count <= K\n\nA = []\nN = int(input())\nK = int(input())\nans = 0\n\nl = 0\nr = 10 ** 9\n\nfor _ in range(N):\n A.append(int(input()))\n\nwhile r - l > 1:\n x = (r + l) // 2\n if is_ok(A, x, K):\n r = x \n else:\n l = x\n \nprint(r)', 'import math\n\ndef is_ok(A, x, K):\n cut_count = 0\n for number in A:\n cut_count += (math.ceil(number / x)) - 1\n return cut_count <= K\n\nA = []\nN = int(input())\nK = int(input())\nans = 0\n\nl = 0\nr = 10 ** 9\n\nfor _ in range(N):\n A.append(int(input()))\n\nwhile r - l > 1:\n x = (r + l) // 2\n if is_ok(A, x, K):\n r = x\n else:\n l = x\n \nprint(r)', 'import math\n\ndef is_ok(A, x, K):\n cut_count = 0\n for number in A:\n cut_count += (math.ceil(number / x)) - 1\n return cut_count <= K\n\nA = []\n[N, K] = input().split()\nN = int(N)\nK = int(K)\nA = input().split()\nans = 0\n\nl = 0\nr = 10 ** 9\n\nfor i in range(N):\n A[i] = int(A[i])\n\nwhile r - l > 1:\n x = (r + l) // 2\n if is_ok(A, x, K):\n r = x\n else:\n l = x\n \nprint(r)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s217317611', 's353621681', 's671085718', 's604893227']
[9072.0, 9144.0, 9156.0, 24956.0]
[32.0, 25.0, 29.0, 1016.0]
[560, 362, 352, 379]
p02598
u347640436
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from math import ceil\nfrom heapq import heapify, heappop, heappush\n\nN, K, *A = map(int, open(0).read().split())\n\nt = sum(A) / K\na = [None] * len(A)\nfor i in A:\n k = max(ceil(i / t), 1)\n a.append((-i / k, i, k))\n\nheapify(a)\nfor _ in range(K):\n i, j, k = heappop(a)\n k += 1\n i = -(j / k)\n heappush(a, (i, j, k))\nprint(ceil(heappop(a)[0] * -1))\n', 'from math import ceil\n\nN, K, *A = map(int, open(0).read().split())\n\ndef is_ok(n):\n t = 0\n for a in A:\n if a <= n:\n continue\n t += ceil(a / n) - 1\n return t <= K\n\nok = 1000000000\nng = 0.0000000001\nwhile abs(ng - ok) > 1:\n m = (ok + ng) // 2\n if is_ok(m):\n ok = m\n else:\n ng = m\n\nprint(ceil(ok))\n']
['Runtime Error', 'Accepted']
['s856589706', 's434869218']
[48644.0, 31436.0]
[204.0, 1155.0]
[360, 351]
p02598
u371409687
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k=map(int,input().split())\na=list(map(int,input().split()))\nif k==0:\n print(max(a))\nelse:\n ans=0\n d=round(max(a)*k/sum(a))\n print(-(-max(a)//(d+1)))', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nif k==0:\n print(max(a))\nelse:\n ans=0\n for i in a:\n d=-(-k*i//sum(a))\n if d>0:\n ans=max(ans,-(-i//(d+1)))\n else:\n ans=max(ans,i)\n print(ans)', 'def check(List,mid):\n tmp=0\n for l in List:\n tmp+=(-(-l//mid)-1)\n return tmp\n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nlo=0\nhi=max(a)+1\n\nwhile hi - lo > 1:\n mid=(lo+hi)//2\n if check(a,mid)<=k:\n hi=mid\n else:\n lo=mid\n\nprint(hi)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s047398292', 's243177414', 's078661922']
[30836.0, 30756.0, 30980.0]
[83.0, 2206.0, 666.0]
[162, 256, 286]
p02598
u408375121
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n, k = map(int, input().split())\na = list(map(int, input().split()))\nlow = 0\ntop = max(a) + 1\n\nwhile top - low > 1:\n mid = (top + low) // 2\n cnt = 0\n for i in range(n):\n if a[i] % mid == 0:\n cnt += a[i] // mid\n else:\n cnt += (a[i] // mid) + 1\n if cnt <= k:\n top = mid\n else:\n low = mid\nprint(low)\n', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\nlow = min(a)\ntop = max(a)\n\nwhile top - low > 1:\n mid = (top + low) // 2\n cnt = 0\n for i in range(n):\n cnt += (a[i] + 1) // mid\n if cnt <= k:\n top = mid\n else:\n low = mid\nprint(low)', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\nlow = 0\ntop = max(a) + 1\n\nwhile top - low > 1:\n mid = (top + low) // 2\n cnt = 0\n for i in range(n):\n if a[i] % mid == 0:\n cnt += (a[i] // mid) - 1\n else:\n cnt += a[i] // mid\n if cnt <= k:\n top = mid\n else:\n low = mid\nprint(low)\n', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\nlow = 0\ntop = max(a) + 1\n\nwhile top - low > 1:\n mid = (top + low) // 2\n cnt = 0\n for i in range(n):\n if a[i] % mid == 0:\n cnt += (a[i] // mid) - 1\n else:\n cnt += a[i] // mid\n if cnt <= k:\n top = mid\n else:\n low = mid\nprint(top)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s052203032', 's648692922', 's733236887', 's427457761']
[30976.0, 30856.0, 30736.0, 30836.0]
[1571.0, 1022.0, 1476.0, 1322.0]
[324, 263, 324, 324]
p02598
u414050834
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\nn,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort(revese=True)\nfor i in range(k):\n t=max(a)\n a.insert(0,t/2)\n a.remove(t)\nprint(math.ceil(max(a)))', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nl,r=0,max(a)\ndef test(x):\n num=0\n for i in a:\n num+=i//x\n if i%x==0:\n num-=1\n if num<=k:\n return num\nwhile r-l>1:\n mid=(l+r)//2\n if test(mid):\n r=mid\n else:\n l=mid\nprint(r)']
['Runtime Error', 'Accepted']
['s450593099', 's912144028']
[31108.0, 30932.0]
[73.0, 619.0]
[180, 260]
p02598
u417365712
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n, k, *A = map(int, open(0).read().split())\nt = sum(A) / (n+k)\nA = [a for a in A if int(a/t) >= 1]\nX = []\nfor a in A:\n X.append(ceil(a / ceil(a/t)))\n X.append(ceil(a / int(a/t)))\nX.sort()\nprint(X[k])', 'from math import modf\nn, k, *A = map(int, open(0).read().split())\nt = sum(A) / (n+k)\nA = [a for a in A if int(a/t) >= 1]\nc = k - sum(int(a/t)-1 for a in A)\nX = []\nfor a in A:\n X.append(ceil(a / ceil(a/t)))\n X.append(ceil(a / int(a/t)))\nX.sort()\nprint(X[-c-1])', 'class BisectSearch:\n def __init__(self, f, l=0, r=10**9):\n self.f = f\n self.l = l\n self.r = r\n def __call__(self, dist):\n f = self.f\n l = self.l\n r = self.r\n if dist <= f(l):\n return l\n if f(r) <= dist:\n return r\n while r-l > 1:\n n = (r+l) // 2\n if f(n) <= dist:\n l = n\n else:\n r = n\n return l, r\n\nn, k, *A = map(int, open(0).read().split())\nprint(BisectSearch(lambda x:k+1-sum(ceil(a/x)-1 for a in A), l=1)(0)[1])', 'from math import modf\nn, k, *A = map(int, open(0).read().split())\nA.sort(reverse=1)\nt = sum(A) / (n+k)\nB = [(modf(a/t - 1)[0], modf(a/t - 1)[1], a) for a in A if a/t > 1]\nB.sort(reverse=1)\nc = k - sum(int(y) for x, y, z in B)\nans = 0\nX = []\nfor i, (_, y, z) in enumerate(B):\n X.append(ceil(z / (y+2)))\n X.append(ceil(z / (y+1)))\nX.sort()\nprint(X[-c-1])', 'n, k, *A = map(int, open(0).read().split())\nt = sum(A) / (n+k)\nA = [a for a in A if int(a/t) >= 1]\nX = []\nfor a in A:\n X.append(ceil(a / ceil(a/t)))\n X.append(ceil(a / int(a/t)))\nX.sort()\nprint(X[k] if k < len(X) else X[-1])', 'from math import ceil\nn, k, *A = map(int, open(0).read().split())\nt = sum(A) / (n+k)\nA = [a for a in A if int(a/t) >= 1]\nX = []\nfor a in A:\n X.append(ceil(a / ceil(a/t)))\n X.append(ceil(a / int(a/t)))\nX.sort()\nprint(X[k] if k < len(X) else X[-1])', 'from math import ceil\nn, k, *A = map(int, open(0).read().split())\nt = sum(A) / (n+k)\nA = [a for a in A if int(a/t) >= 1]\nX = []\nfor a in A:\n X.append(ceil(a / ceil(a/t)))\n X.append(ceil(a / int(a/t)))\nX.sort()\nprint(X[sum(int(a/t)-1 for a in A) -k-1])']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s280337959', 's326709552', 's377084950', 's408172590', 's437027693', 's722926477', 's926555309']
[31608.0, 31504.0, 31564.0, 45056.0, 31592.0, 34600.0, 34680.0]
[107.0, 131.0, 68.0, 491.0, 108.0, 286.0, 325.0]
[205, 265, 575, 358, 230, 252, 257]
p02598
u423389475
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k = map(int,input().split())\na = list(map(int,input().split()))\ndef check(t):\n ans = 0\n for aa in a:\n if aa > t:\n ans += aa//t\nmax = 10**9\nmin = 0\nwhile max-min>1:\n mid = (max+min)/2\n if check(mid):\n max = mid\n else:\n min = mid\nprint(max)', 'import sys\nimport math\nn,k = map(int,input().split())\na = list(map(int,input().split()))\nif k ==0:\n print(max(a))\n sys.exit()\ndef check(t):\n ans = 0\n if t==0:\n return False\n for aa in a:\n if aa > t:\n ans += aa//t\n return ans <= k\nmax = 10**9+1\nmin = 0\nwhile max-min>1:\n mid = (max+min)//2\n if check(mid):\n max = mid\n else:\n min = mid\nprint(math.ceil(max))']
['Wrong Answer', 'Accepted']
['s163695073', 's578316144']
[30832.0, 31088.0]
[808.0, 481.0]
[259, 381]
p02598
u423624748
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nleq,high = 0,1e10\nwhile high-leq > 1:\n l = int((leq+high)/2)\n cnt = 0\n for ai in a:\n cnt += int((ai-1)/l)\n print(l,cnt)\n if cnt>k:\n leq = l\n else:\n high = l\n\nprint(high)', 'n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nleq,high = 0,1e10\nwhile high-leq > 1:\n l = int((leq+high)/2)\n cnt = 0\n for ai in a:\n cnt += int((ai-1)/l)\n print(l,cnt)\n if cnt>k:\n leq = l\n else:\n high = l\n\nprint(high)', 'n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nleq,high = 0,1e10\nwhile high-leq > 1:\n l = int((leq+high)/2)\n cnt = 0\n for ai in a:\n cnt += int((ai-1)/l)\n if cnt>k:\n leq = l\n else:\n high = l\n\nprint(high)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s342685384', 's719022528', 's867106448']
[30780.0, 30824.0, 30624.0]
[1467.0, 1434.0, 1493.0]
[251, 251, 236]
p02598
u462976050
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\nN, K = map(int, input().split())\nA=list(map(int,input().split()))\nmaxA = max(A)\nnum = 0\nright = maxA\nleft = 0\nwhile(right-left>1):\n num = left+math.floor((right-left)*0.5)\n count = 0\n for i in range(len(A)):\n count += math.ceil(A[i]/num)-1\n if count > K:\n left = num\n elif count < K:\n right = num\ncount = 0\nnum = right\nfor i in range(len(A)):\n count += math.ceil(A[i]/num)-1\nif count!=K:\n num = left\n count = 0\n for i in range(len(A)):\n count += math.ceil(A[i]/num)-1\nprint(num)\n', 'N, K = map(int, input().split())\nA=list(map(int,input().split()))\nA.sort()\nright = A[-1]+1\nleft = -1\nflag = True\nmid = (left+right)//2\nwhile right-left>1 and flag:\n mid = (left+right)//2\n count = 0\n for i in A:\n count += (i-1)//mid\n if count <= K:\n right = mid\n elif count > K:\n left = mid\n else:\n flag = False\nprint(mid)\n', 'import math\nN, K = map(int, input().split())\nA=list(map(int,input().split()))\nmaxA = max(A)\nright = maxA\nleft = 0\nwhile(right-left>1):\n mid = (left+right)//2\n count = 0\n for i in A:\n count += (i-1)//mid\n if count > K:\n left = mid\n elif count <= K:\n right = mid\nprint(mid)\n', 'import math\nN, K = map(int, input().split())\nA=list(map(int,input().split()))\nright = 20000000000000\nleft = 0\nwhile(right-left>1):\n mid = (left+right)//2\n count = 0\n for i in A:\n count += (i-1)//mid\n if count > K:\n left = mid\n else:\n right = mid\nprint(mid)\n', 'N, K = map(int, input().split())\nA=list(map(int,input().split()))\nA.sort()\nright = A[-1]+1\nleft = -1\nflag = True\nwhile right-left>1 and flag:\n mid = (left+right)//2\n count = 0\n for i in A:\n count += (i-1)//mid\n if count <= K:\n right = mid\n elif count > K:\n left = mid\n else:\n flag = False\nprint(mid)\n', 'N, K = map(int, input().split())\nA=list(map(int,input().split()))\nA.sort()\nright = A[-1]+1\nleft = 0\nflag = True\nmid = (left+right)//2\nminN = right\nresult = mid\nwhile right-left>1 and flag:\n mid = (left+right)//2\n count = 0\n for i in A:\n count += (i-1)//mid\n if count <= K:\n right = mid\n if minN>mid:\n minN = mid\n result = mid\n elif count > K:\n left = mid\nprint(result)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s410237953', 's430101121', 's517259604', 's832533235', 's847312022', 's446886738']
[31028.0, 30768.0, 31192.0, 30956.0, 30980.0, 30884.0]
[2206.0, 1052.0, 868.0, 1247.0, 1066.0, 1044.0]
[546, 368, 308, 293, 346, 434]
p02598
u474202990
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k = map(int,input().split())\nA = list(map(int,input().split()))\n\nl = min(A)//(k+1) \nr = max(A)\nm = (l+r)//2+1\n\nwhile 1:\n \n m = (l+r)//2\n \n \n \n # A_long = A[A>m]\n n= sum( [A[i]//m - A[i]%m==0 for i in range(len(A)) ] )\n \n # print(l,m,r,n)\n \n if n<=k:\n if r==m:\n break\n r=m-1\n else:\n if l==m:\n m=m+1\n break\n l=m+1\n \n\n \nprint(m)\n ', 'n,k = map(int,input().split())\nA = list(map(int,input().split()))\n\nl = min(A)//(k+1) \nr = max(A)\nm = (l+r)//2+1\n\nwhile 1:\n \n m = (l+r)//2\n \n \n \n # A_long = A[A>m]\n n= sum( [ int((A[i]-0.1)//(m)) for i in range(len(A)) ] )\n \n print(l,m,r,n)\n \n if n<=k:\n if r==m:\n break\n r=m-1\n else:\n if l==m:\n m+=1\n break\n l=m+1\n \n\n \nprint(m)', '\nn,k = map(int,input().split())\nA = list(map(int,input().split()))\n\nl = min(A)//(k+1) \nr = max(A)\nm = (l+r)//2+1\n\nwhile 1:\n \n m = (l+r)//2\n \n \n \n # A_long = A[A>m]\n n= sum( [A[i]+0.1//m for i in range(len(A)) ] )\n \n # print(l,m,r,n)\n \n if n<=k:\n if r==m:\n break\n r=m-1\n else:\n if l==m:\n m=m+1\n break\n l=m+1\n \n\n \nprint(m)\n ', 'n,k = map(int,input().split())\nA = list(map(int,input().split()))\n\nl = min(A)//(k+1) \nr = max(A)\nm = (l+r)//2+1\n\nwhile 1:\n \n m = (l+r)//2\n \n if m==0:\n m=1\n break\n \n \n \n # A_long = A[A>m]\n n= sum( [ int((A[i]-0.1)//(m)) for i in range(len(A)) ] )\n \n # print(l,m,r,n)\n \n if n<=k:\n if r==m:\n break\n r=m-1\n else:\n if l==m:\n m+=1\n break\n l=m+1\n \n\n ', 'n,k = map(int,input().split())\nA = list(map(int,input().split()))\n\nl = min(A)//(k+1) \nr = max(A)\nm = (l+r)//2+1\n\nwhile 1:\n \n m = (l+r)//2\n if m==0:\n m=1\n break\n\n \n \n \n # A_long = A[A>m]\n n= sum( [ int((A[i]-0.1)//(m)) for i in range(len(A)) ] )\n \n # print(l,m,r,n)\n \n if n<=k:\n if r==m:\n break\n r=m-1\n else:\n if l==m:\n m+=1\n break\n l=m+1\n \n\n \nprint(m)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s132507129', 's640976758', 's970582941', 's991740108', 's246854171']
[30788.0, 30628.0, 30832.0, 30888.0, 30544.0]
[2206.0, 1783.0, 1131.0, 1919.0, 1807.0]
[482, 477, 475, 514, 519]
p02598
u476386869
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['input = open("input.in").readline\n\ndef main():\n N,K = map(int, input().split())\n A = list(map(int, input().split()))\n \n l,r = 0, max(A)\n while l < r-1:\n mid = l + (r-l)//2\n cnt = 0\n for a in A:\n cnt+= a//mid\n \n if cnt <= K:\n r = mid\n else:\n l = mid\n print(r)\n \nmain()', 'import sys\ninput = sys.stdin.readline\n\ndef main():\n N,K = map(int, input().split())\n A = list(map(int, input().split()))\n \n l,r = 0, max(A)\n while l < r-1:\n mid = (l+r)//2\n cnt = 0\n for a in A:\n if a % mid:\n cnt+= a//mid\n else:\n cnt += a//mid - 1\n \n if cnt <= K:\n r = mid\n else:\n l = mid\n print(r)\n \nmain()']
['Runtime Error', 'Accepted']
['s191405018', 's198589869']
[9044.0, 31088.0]
[30.0, 572.0]
[367, 447]
p02598
u503228842
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from bisect import bisect_left\nn, k = map(int, input().split())\na = list(map(int, input().split()))\na.sort(reverse=True)\nok = 0\nng = 10**10\n\n\ndef judge(l):\n cnt = 0\n for aa in a:\n if aa <= l:\n break\n while aa > l:\n aa /= 2\n cnt += 1\n return cnt <= k\n\n\nwhile abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if judge(mid):\n ok = mid\n else:\n ng = mid\nprint(ok)\n', 'from math import ceil\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nok = 10**10\nng = 0\n\n\ndef judge(x):\n cnt = 0\n for aa in a:\n cnt += (x + aa - 1) // x - 1\n # print(cnt)\n return cnt <= k\n\n\n# print(judge(4))\n# print(judge(5))\n# print(judge(3))\n\nwhile abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if judge(mid):\n ok = mid\n else:\n ng = mid\nprint(ok)\n']
['Wrong Answer', 'Accepted']
['s021678436', 's260526748']
[30956.0, 31064.0]
[110.0, 941.0]
[430, 412]
p02598
u514334797
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['def count(N,K,mid,a):\n cnt = 0\n for i in range(N):\n cnt = a[i]//mid\n if cnt > K:\n return False\n else:\n return True\n\ndef main():\n N, K = map(int, input().split())\n a = list(map(int, input().split()))\n\n low = 1\n high = 10**9\n mid = (low+high)//2\n\n while high > low+1:\n if count(N,K,mid,a):\n high = mid\n else:\n low = mid\n mid = (low+high)//2\n \n if count(N,K,low,a):\n print(high)\n else:\n print(low)\n\nmain()', 'import math\n\ndef count(N,K,mid,a):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(a[i]/mid-1)\n if cnt > K:\n return False\n else:\n return True\n\ndef main():\n N, K = map(int, input().split())\n a = list(map(int, input().split()))\n\n low = 1\n high = 10**9+1\n mid = (low+high)//2\n\n while high > low+1:\n if count(N,K,mid,a):\n high = mid\n else:\n low = mid\n mid = (low+high)//2\n \n if count(N,K,low,a):\n print(low)\n else:\n print(high)\n\nmain()']
['Wrong Answer', 'Accepted']
['s857383683', 's633246288']
[30828.0, 31112.0]
[390.0, 1160.0]
[519, 547]
p02598
u525796732
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import sys\nimport math\nimport fractions\nfrom collections import defaultdict\nimport heapq\nfrom bisect import bisect_left,bisect\n\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,K=nm()\nA=nl()\nl=1\nr=10**9\nmid=0\n\nif(K==0):\n print(max(A))\n sys.exit(0)\n\nwhile(l+1<r):\n mid=(l+r)//2\n tmp=0\n for i in range(len(A)):\n tmp+=A[i]//mid\n if(K<tmp):\n l=mid\n else:\n r=mid\n\ntmp=0\nfor i in range(len(A)):\n tmp+=A[i]//l\n\ntmp2=0\nfor i in range(len(A)):\n tmp2+=A[i]//r\n\n\nif(tmp<=K)\n print(l)\n sys.exit(0)\n \n print(r)\n\n\n\n\n ', 'import sys\nimport math\nimport fractions\nfrom collections import defaultdict\nimport heapq\nfrom bisect import bisect_left,bisect\n\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,K=nm()\nA=nl()\nl=1\nr=10**9\nmid=0\n\nif(K==0):\n print(max(A))\n sys.exit(0)\n\nwhile(l+1<r):\n mid=(l+r)//2\n tmp=0\n for i in range(len(A)):\n tmp+=(A[i]//mid if A[i]%mid==0 else A[i]//mid+1) \n if(K<tmp):\n l=mid\n else:\n r=mid\n\ntmp=0\nfor i in range(len(A)):\n tmp+=(A[i]//l if A[i]%l==0 else A[i]//l+1) \n\nif(K<=tmp):\n print(r)\n sys.exit(0)\nelse:\n print(l)\n sys.exit(0)\n\n\n ', 'import sys\nimport math\nimport fractions\nfrom collections import defaultdict\nimport heapq\nfrom bisect import bisect_left,bisect\n\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,K=nm()\nA=nl()\nl=1\nr=10**9\nmid=0\n\nif(K==0):\n print(max(A))\n sys.exit(0)\n\nwhile(l+1<r):\n mid=(l+r)//2\n tmp=0\n \n for i in range(len(A)):\n if((A[i])%mid):\n tmp=((A[i])//mid)-1\n else\n tmp=((A[i])//mid)\n if(tmp<=K):\n r=mid\n else:\n l=mid\n\nprint(r)', 'import sys\nimport math\nimport fractions\nfrom collections import defaultdict\nimport heapq\nfrom bisect import bisect_left,bisect\n\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,K=nm()\nA=nl()\nl=1\nr=10**9\nmid=0\n\nif(K==0):\n print(max(A))\n sys.exit(0)\n\nwhile(l+1<r):\n mid=(l+r)//2\n tmp=0\n for i in range(len(A)):\n tmp+=(A[i]//mid if A[i]%mid==0 else A[i]//mid+1) \n if(K<tmp):\n l=mid\n else:\n r=mid\n\ntmp=0\nfor i in range(len(A)):\n tmp+=A[i]//l\n\nif(K<=tmp):\n print(r)\n sys.exit(0)\nelse:\n print(l)\n sys.exit(0)\n\n\n ', 'import sys\nimport math\nimport fractions\nfrom collections import defaultdict\nimport heapq\nfrom bisect import bisect_left,bisect\n\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,K=nm()\nA=nl()\nl=1\nr=10**9\nmid=0\n\nif(K==0):\n print(max(A))\n sys.exit(0)\n\nwhile(l+1<r):\n mid=(l+r)//2\n tmp=0\n for i in range(len(A)):\n tmp+=A[i]//mid\n if(K<tmp):\n l=mid\n else:\n r=mid\n\ntmp=0\nfor i in range(len(A)):\n tmp+=A[i]//l\n\ntmp2=0\nfor i in range(len(A)):\n tmp2+=A[i]//r\n\n\nif(tmp<=K):\n print(l)\n sys.exit(0)\n\n print(r)\n\n\n\n\n ', 'import sys\nimport math\nimport fractions\nfrom collections import defaultdict\nimport heapq\nfrom bisect import bisect_left,bisect\n\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,K=nm()\nA=nl()\nl=0\nr=10**9\nmid=0\n\nif(K==0):\n print(max(A))\n sys.exit(0)\n\nwhile(l+1<r):\n mid=(l+r)//2\n tmp=0\n for i in range(len(A)):\n if((A[i])%mid==0):\n tmp+=((A[i])//mid)-1\n else:\n tmp+=((A[i])//mid)\n if(tmp<=K):\n r=mid\n else:\n l=mid\n\nprint(r)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s329174152', 's415274916', 's481413151', 's487389417', 's648064906', 's918528571']
[9028.0, 32284.0, 8940.0, 32104.0, 9036.0, 32196.0]
[27.0, 1509.0, 27.0, 1740.0, 29.0, 1417.0]
[727, 761, 653, 730, 724, 654]
p02598
u539367121
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["def main():\n l,r=0,10**9\n while r-l>1:\n m=(l+r)//2\n if sum([(i-1)//x for i in a])<=k: r=m;\n else: l=m;\n print(r)\n\nif __name__=='__main__':\n n,k=map(int,input().split())\n a=list(map(int,input().split()))\n main()", "def main():\n l,r=0,10**9\n while r-l>1:\n m=(l+r)//2\n if sum([(i-1)//m for i in a])<=k: r=m;\n else: l=m;\n print(r)\n\nif __name__=='__main__':\n n,k=map(int,input().split())\n a=list(map(int,input().split()))\n main()"]
['Runtime Error', 'Accepted']
['s739786056', 's281249110']
[30900.0, 30832.0]
[72.0, 521.0]
[225, 225]
p02598
u543016260
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['N, K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef judge(ans,K,A):\n cut=0\n for i in range(len(A)):\n cut+=(A[i]-1)//ans\n if cut>K:\n return False\n else:\n return True\n\n\nansp=max(A)\nansm=min(A)\nans=(ansp+ansm)//2\nd=1\nwhile ansp-ansm>d:\n \n if judge(ans,K,A):\n ansp=ans\n \n else:\n ansm=ans\n \n ans=(ansp+ansm)//2\nprint(ansp)', 'import math\nN, K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef judge(ans,K,A):\n cut=0\n for i in range(len(A)):\n cut+=A[i]//ans\n if cut>K:\n return False\n else:\n return True\n\n\nansp=max(A)\nansm=min(A)\nans=(ansp+ansm)//2\nd=1\nwhile ansp-ansm>d:\n \n if judge(ans,K,A):\n ansp=ans\n \n else:\n ansm=ans\n \n ans=(ansp+ansm)//2\nprint(ansp)', 'N, K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef judge(ans,K,A):\n cut=0\n for i in range(len(A)):\n cut+=int(A[i]/int(ans+1))\n if cut>K:\n return False\n else:\n return True\n\n\nansp=max(A)\nansm=min(A)\nans=int((ansp+ansm)/2+1)\nwhile True:\n \n if judge(ans,K,A):\n ansp1=((ansp+ans)/2)\n if ansp1==ansp:\n break\n else:\n ansp=ansp1\n else:\n ansm1=((ans+ansm)/2)\n if ansm1==ansm:\n break\n else:\n ansm=ansm1\n ans=(ansp+ansm)/2\nif ans-int(ans)<0.00000001:\n print(int(ans))\nelse:\n print(int(ans)+1)', 'import math\nN, K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef judge(ans,K,A):\n cut=0\n for i in range(len(A)):\n cut+=(A[i]-1)//ans\n if cut>K:\n return False\n else:\n return True\n\n\nansp=max(A)\nansm=0\nans=(ansp+ansm)//2\nd=1\nwhile ansp-ansm>d:\n \n if judge(ans,K,A):\n ansp=ans\n \n else:\n ansm=ans\n \n ans=(ansp+ansm)//2\nprint(ansp)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s081327880', 's123546092', 's984250403', 's240722163']
[30888.0, 31064.0, 30800.0, 30972.0]
[638.0, 505.0, 2206.0, 623.0]
[406, 414, 635, 413]
p02598
u570155187
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from math import ceil\nn,k = map(int,input().split())\na = list(map(int,input().split()))\n\nprint(n,k,a)\n\ndef cut(x):\n t = 0\n for i in a:\n if i <= x:\n continue\n t += ceil(i / x) - 1\n return t <= k\n\nl,r=0,10**9\nwhile l+1 < r:\n x = l + (r-l)//2\n if cut(x):\n r = x\n else:\n l = x\nprint(r)', 'from math import ceil\nn,k = map(int,input().split())\na = list(map(int,input().split()))\n\ndef cut(x):\n t = 0\n for i in a:\n if i <= x:\n continue\n t += ceil(i / x) - 1\n return t <= k\n\nl,r=0,10**9\nwhile l+1 < r:\n x = l + (r-l)//2\n if cut(x):\n r = x\n else:\n l = x\nprint(r)']
['Wrong Answer', 'Accepted']
['s334774375', 's895273108']
[31204.0, 31172.0]
[920.0, 986.0]
[304, 290]
p02598
u595353654
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['##a = int(stdin.readline().rstrip())\n##b, c = [int(x) for x in stdin.readline().rstrip().split()]\n##s = stdin.readline().rstrip()\n\n##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]\n##a = [[0] * 2 for _ in range(n)] a[0,0]\n\n\n\n\n\n\n# -*- coding: utf-8 -*-\nfrom sys import stdin\nfrom operator import itemgetter\nfrom collections import deque, Counter\nimport math\nimport pprint\nfrom functools import reduce\nimport numpy as np\nimport random\nimport bisect\nimport copy\n\n\n\nMOD = int(1e9+7)\nINF = float(\'inf\')\nalpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]\n\ndef keta(kazu): \n kazu_str = str(kazu)\n kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]\n return kazu_list\n\ndef gcd(*numbers): \n return reduce(math.gcd, numbers)\n\ndef combination(m,n): # mCn\n \n if n > m:\n return \'すまん\'\n return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))\n\ndef pow_k(x,n): \n if n == 0:\n return 1\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n return K * x\n\ndef fact(n): \n arr = {}\n temp = n\n for i in range(2,int(n**0.5)+1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr[i] = cnt\n if temp != 1:\n arr[temp] = 1\n if arr == {}:\n arr[n] = 1\n return arr\n \ndef f(n,a,c,K):\n now = 0\n for i in range(n):\n now += math.ceil(a[i]/c)-1\n return now <= K\n\ndef main():\n N,K = [int(x) for x in stdin.readline().rstrip().split()]\n A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))\n l,r = 0,int(1e9)\n while r-l > 1:\n c = (l+r)//2\n print(c,f(N,A,c,K))\n if f(N,A,c,K):\n r = c\n else:\n l = c\n \n print(r)\nmain()', '##a = int(stdin.readline().rstrip())\n##b, c = [int(x) for x in stdin.readline().rstrip().split()]\n##s = stdin.readline().rstrip()\n\n##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]\n##a = [[0] * 2 for _ in range(n)] a[0,0]\n\n\n\n\n\n\n# -*- coding: utf-8 -*-\nfrom sys import stdin\nfrom operator import itemgetter\nfrom collections import deque, Counter\nimport math\nimport pprint\nfrom functools import reduce\nimport numpy as np\nimport random\nimport bisect\nimport copy\n\n\n\nMOD = int(1e9+7)\nINF = float(\'inf\')\nalpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]\n\ndef keta(kazu): \n kazu_str = str(kazu)\n kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]\n return kazu_list\n\ndef gcd(*numbers): \n return reduce(math.gcd, numbers)\n\ndef combination(m,n): # mCn\n \n if n > m:\n return \'すまん\'\n return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))\n\ndef pow_k(x,n): \n if n == 0:\n return 1\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n return K * x\n\ndef fact(n): \n arr = {}\n temp = n\n for i in range(2,int(n**0.5)+1):\n if temp % i == 0:\n cnt = 0\n while temp % i == 0:\n cnt += 1\n temp //= i\n arr[i] = cnt\n if temp != 1:\n arr[temp] = 1\n if arr == {}:\n arr[n] = 1\n return arr\n \ndef f(n,a,c,K):\n now = 0\n for i in range(n):\n now += math.ceil(a[i]/c)-1\n return now <= K\n\ndef main():\n N,K = [int(x) for x in stdin.readline().rstrip().split()]\n A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))\n l,r = 0,int(1e9)\n while r-l > 1:\n c = (l+r)//2\n \n if f(N,A,c,K):\n r = c\n else:\n l = c\n \n print(r)\nmain()']
['Wrong Answer', 'Accepted']
['s551650910', 's700490202']
[49360.0, 49444.0]
[2206.0, 1208.0]
[2506, 2508]
p02598
u599969606
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["import math\n\ndef main():\n _, k = map(int, input().split())\n arr = list(map(int, input().split()))\n print(arr)\n l, r = 1, 1000000000\n while l < r:\n m = (l + r) // 2\n cnt = 0\n for val in arr:\n cnt += math.ceil(val / m) - 1\n if cnt > k:\n l = m + 1\n else:\n r = m\n print(l)\n \nif __name__ == '__main__':\n main()", "import math\n\ndef main():\n _, k = map(int, input().split())\n arr = list(map(int, input().split()))\n l, r = 1, 1000000000\n while l < r:\n m = (l + r) // 2\n cnt = 0\n for val in arr:\n cnt += math.ceil(val / m) - 1\n if cnt > k:\n l = m + 1\n else:\n r = m\n print(l)\n \nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s959230984', 's175535809']
[31100.0, 31032.0]
[1015.0, 987.0]
[395, 380]
p02598
u614181788
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k = map(int,input().split())\na = list(map(int,input().split()))\na = sorted(a,reverse=True)\ns = sum(a)\nx = [0]*n\ny = 0\nfor i in range(n):\n y = int(a[i]/s*k)\n x[i] = [i, (a[i]/s*k)%1, y]\n\nx.sort(key= lambda val : val[1],reverse=True)\nfor i in range(k-y):\n x[i][2] += 1\nans = 0\nz = 0\nfor i in range(n):\n ans = max(ans, a[x[i][0]-1]/(x[i][2]+1))\n z += x[i][2]\nprint(int(-(-ans//1)))', 'def is_ok(arg):\n \n c = 0\n for x in a:\n c += -(-x//arg) - 1\n return c <= k\n\ndef meguru_bisect(ng, ok):\n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\nn,k = map(int,input().split())\na = list(map(int,input().split()))\nprint(meguru_bisect(0,10**9+1))']
['Runtime Error', 'Accepted']
['s354933663', 's855034215']
[59444.0, 31164.0]
[471.0, 649.0]
[395, 427]
p02598
u615520489
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
["#import numpy as np\n#import collections\n#import math\n\nf = open('./input_E.txt')\n\nN,K = map(int, f.readline().split())\nA = list(map(int, f.readline().split()))\n\n#N,K = map(int, input().split())\n#A = list(map(int, input().split()))\n\nA.sort(reverse=True)\n\ndef nibu(small,big):\n mid = (small+big)//2\n# k_list = [x//mid for x in A2]\n k_list = [x//mid for x in A]\n sum_k = sum(k_list)\n if sum_k <= K: \n return small,mid \n else:\n return mid,big \n\n\nif N==1 or K==0:\n ans = A[0]\nelse: \n# All_length = sum(A)\n# KK = K+N-1\n\n lmin = 0\n \n# A2 = [x for x in A if x > lmin]\n \n# Kper1 = K//len(A2)\n \n\n lmax = A[1]\n \n while lmax - lmin >= 2:\n lmin, lmax = nibu(lmin,lmax)\n \n ans = lmax\n \nprint(ans)", "#import numpy as np\n#import collections\n#import math\n\n#f = open('./input_E.txt')\n#\n#N,K = map(int, f.readline().split())\n#A = list(map(int, f.readline().split()))\n\nN,K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA.sort(reverse=True)\n\ndef nibu(small,big,KK,AA):\n mid = (small+big)//2\n k_list = [(x+1)//mid for x in AA]\n sum_k = sum(k_list)\n if sum_k <= KK: \n return small,mid \n else:\n return mid,big \n\n\nif K==0:\n ans = A[0]\nelse: \n lmin = 0\n lmax = A[0]\n \n while lmax - lmin >= 2:\n lmin, lmax = nibu(lmin,lmax,K,A)\n \n ans = lmax\n \nprint(ans)", "#import numpy as np\n#import collections\n#import math\n\n#f = open('./input_E.txt')\n#\n#N,K = map(int, f.readline().split())\n#A = list(map(int, f.readline().split()))\n\nN,K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA.sort(reverse=True)\n\nAll_length = sum(A)\nKK = K+N-1\nlm = All_length/KK\n\nk_list = [int(Ai//lm) for Ai in A]\nX_list = [Ai%lm for Ai in A]\n\nsum_k = sum(k_list)\nres_cut = KK-sum_k\n\nzero_k = 0\nfor i in range(1,N+1):\n if k_list[-i] == 0:\n zero_k +=1\n else:\n break\n\nif res_cut > 0:\n ans_kouho = []\n for i in range(-zero_k,0):\n ans_kouho.append(X_list[i])\n for i in range(res_cut):\n for j in range(N-zero_k):\n ans_kouho.append((X_list[j]-i*lm)/k_list[j])\n \n ans_kouho.sort(reverse=True)\n ans = ans_kouho[res_cut] + lm\n ans = int(ans)+1\nelse:\n ans = int(lm)+1\nprint(ans)", "#import numpy as np\n#import collections\n#import math\n\n#f = open('./input_E.txt')\n#\n#N,K = map(int, f.readline().split())\n#A = list(map(int, f.readline().split()))\n\nN,K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA.sort(reverse=True)\n\ndef nibu(small,big,KK,AA):\n mid = (small+big)//2\n k_list = [(x-1)//mid for x in AA]\n sum_k = sum(k_list)\n if sum_k <= KK: \n return small,mid \n else:\n return mid,big \n\n\nif K==0:\n ans = A[0]\nelse: \n lmin = 0\n lmax = A[0]\n \n while lmax - lmin >= 2:\n lmin, lmax = nibu(lmin,lmax,K,A)\n \n ans = lmax\n \nprint(ans)"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s140276899', 's191684384', 's390694108', 's247637285']
[9076.0, 30788.0, 412184.0, 30804.0]
[27.0, 878.0, 2221.0, 788.0]
[917, 704, 864, 704]
p02598
u629350026
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k=map(int,input().split())\na=list(map(int,input().split()))\ntmax=max(a)\ntmin=0\nt=(tmax+tmin)//2\nimport math\nans=tmax\nif k==0:\n print(tmax)\nelse:\n while True:\n s=0\n for i in range(n):\n s=s+math.ceil(a[i]/t)-1\n if k>=s:\n ans=min(math.ceil(t),math.ceil(ans))\n tmax=t\n t=(tmin+t)//2\n else:\n tmin=t\n t=(t+tmax)//2\n if tmax-tmin<0.01:\n break\n print(ans)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\ntmax=max(a)\ntmin=0\nimport math\nans=tmax\nif k==0:\n print(tmax)\nelse:\n while True:\n t=(tmax+tmin)//2\n if abs(tmax-tmin)<=1:\n break\n s=0\n for i in range(n):\n s=s+math.ceil(a[i]/t)-1\n if k>=s:\n ans=min(math.ceil(t),ans)\n tmax=t\n else:\n tmin=t\n print(ans)']
['Runtime Error', 'Accepted']
['s482166450', 's861536207']
[30916.0, 30820.0]
[2206.0, 1462.0]
[402, 358]
p02598
u633355062
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import numpy as np\nimport math\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\ndef is_ok(i):\n su = 0\n for a in A:\n su += math.ceil(n / i) - 1\n if su <= K:\n return True\n else:\n return False\n\ndef meguru_bisect(ng, ok):\n \n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\nprint(meguru_bisect(0, max(A) + 1))', 'import numpy as np\nimport math\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\ndef is_ok(i):\n su = 0\n for a in A:\n su += math.ceil(a / i) - 1\n if su <= K:\n return True\n else:\n return False\n\ndef meguru_bisect(ng, ok):\n \n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\nprint(meguru_bisect(0, max(A) + 1))']
['Runtime Error', 'Accepted']
['s599947574', 's881226695']
[49600.0, 49320.0]
[177.0, 1076.0]
[753, 753]
p02598
u648868410
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import numpy as np\nimport math\n\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef isOK(minVal):\n\ttmpK=0\n\tfor a in A:\n\t\t\n\t\ttmpK+=((-(-a//minVal))-1)\n\n\tif tmpK <= K:\n\t\treturn True\n\telse:\n\t\treturn False\n\nok = max(A)\nng = 0\n\nwhile (math.ceil(ok) != math.ceil(ng)):\n\tmid = (ok+ng) / 2\n\tif isOK(mid):\n\t\tok = mid\n\telse:\n\t\tng = mid\n\tprint(ok,ng)\n\nprint(math.ceil(ok))', 'import numpy as np\nimport math\n\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndef isOK(minVal):\n\ttmpK=0\n\tfor a in A:\n\t\t\n\t\ttmpK+=((-(-a//minVal))-1)\n\n\tif tmpK <= K:\n\t\treturn True\n\telse:\n\t\treturn False\n\nok = max(A)\nng = 0\n\nwhile (math.ceil(ok) != math.ceil(ng)):\n\tmid = (ok+ng) / 2\n\tif isOK(mid):\n\t\tok = mid\n\telse:\n\t\tng = mid\n\t#print(ok,ng)\n\nprint(math.ceil(ok))']
['Wrong Answer', 'Accepted']
['s973057715', 's173369114']
[49564.0, 49208.0]
[1463.0, 1455.0]
[400, 401]
p02598
u688587139
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\n\nN, K = map(int, input().split())\nlogs = list(map(int, input().split()))\n\nng_len = 1\nok_len = 1000000000\n\n\ndef possible_len(length: int, log: list, k: int):\n count = 0\n for i in range(N):\n count += math.ceil(log[i] / length) - 1\n if count <= k:\n return True\n else:\n return False\n\n\nwhile ok_len - ng_len > 1:\n mid = (ng_len + ok_len) // 2\n if possible_len(mid, logs, K):\n ok_len = mid\n else:\n ng_len = mid\n\n\n\n# print(ng_len)\n# else:\n print(ok_len)\n', 'import math\n\nN, K = map(int, input().split())\nlogs = list(map(int, input().split()))\n\nng_len = 0\nok_len = 1000000000\n\n\ndef possible_len(length: int, log: list, k: int):\n count = 0\n for i in range(N):\n count += math.ceil(log[i] / length) - 1\n if count <= k:\n return True\n else:\n return False\n\n\nwhile ok_len - ng_len > 1:\n mid = (ng_len + ok_len) // 2\n if possible_len(mid, logs, K):\n ok_len = mid\n else:\n ng_len = mid\n\nprint(ok_len)\n']
['Wrong Answer', 'Accepted']
['s588268753', 's944777038']
[31120.0, 31232.0]
[1118.0, 1183.0]
[557, 488]
p02598
u699522269
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\nN,K = map(int,input().split())\ncs = list(map(int, input().split()))\nma = max(cs)\nmi = 0\nrgl = math.ceil(math.log2(ma))\nrt = ma+1\ndef counter(ch,mo):\n rt =math.ceil(ch/mo)\n return rt-1 if rt > 0 else 0\n\nfor _ in range(rgl):\n cnt = 0\n for c in cs:\n cnt+=counter(c,ma)\n if cnt <= K and ma < rt:\n rt = ma\n ma = math.ceil((ma+mi)/2)\n else:\n tmp = ma\n ma += math.ceil((ma-mi)/2)\n mi = tmp\n\nprint(rt)', 'import math\nN,K = map(int,input().split())\ncs = list(map(int, input().split()))\nhigh = max(cs) + 1 \nlow = 0 \n \nwhile high - low > 1:\n x = (high - low) // 2 + low\n cnt = 0\n for a in cs:\n cnt += math.ceil(a/x) - 1\n \n if cnt <= K: # OK\n high = x\n else:\n low = x\nprint(high)\n']
['Wrong Answer', 'Accepted']
['s519526578', 's593489376']
[31096.0, 31236.0]
[1698.0, 1349.0]
[429, 325]
p02598
u700805562
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['N, K = map(int, input().split())\na = list(map(int, input().split()))\nmax_a = 10**9\nmin_a = 0\n\nwhile max_a-min_a>1:\n count = K\n mean_a = (max_a+min_a)//2\n \n for i in range(N):\n if a[i]==mean_a: continue\n count -= -a[i]//mean_a\n if count >= 0:\n max_a = mean_a\n else:\n min_a = mean_a\n\nprint(max_a)', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nmax_l = 10**9\nmin_l = 0\nwhile max_l - min_l != 1:\n count = 0\n mean = (max_l+min_l)//2\n for i in range(n):\n count += -(-a[i]//mean)-1\n if count <= k:\n max_l = mean\n else:\n min_l = mean\nprint(max_l)']
['Wrong Answer', 'Accepted']
['s478099015', 's710406316']
[30828.0, 30976.0]
[1365.0, 1178.0]
[340, 302]
p02598
u703528810
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['from math import ceil\n\ndef check(A,N,i,K):\n cnt=0\n for j in range(N):\n cnt+=ceil(A[j]/i)-1\n if cnt<=K:\n return 1\n else:\n return -1\n\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\nA.sort()\nM=A[-1]\nres=[0 for _ in range(M+1)]\ni=M//2\nd=M//2\nif K==0:\n print(M)\nelse:\n while True:\n d//=2\n res[i]=check(A,N,i,K)\n if i>0 and res[i-1]*res[i]==-1:\n ans=i\n break\n elif i<M and res[i]*res[i+1]==-1:\n ans=i+1\n break\n if res[i]==1:\n i-=d\n else:\n i+=d\n print(ans)\n print(res)', 'from math import ceil\n\ndef check(x):\n cnt = 0\n for a in A:\n cnt += ceil(a/x)-1\n return cnt <= K\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nleft = 0\nright = max(A)\nwhile left < right-1:\n mid = (left+right)//2\n if check(mid):\n right = mid\n else:\n left = mid\nprint(right)\n']
['Runtime Error', 'Accepted']
['s468190762', 's573151495']
[656328.0, 31112.0]
[2227.0, 810.0]
[629, 336]
p02598
u711677620
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndef check(1):\n count = 0\n for L in A:\n count = count + L // 1\n if L % 1 != 0:\n count = count + 1\n count = count - 1\n return count <= K\n\nbottom, top = 0, max(A)\n\nwhile top - bottom > 1:\n mid = (top + bottom) // 2\n if check(mid):\n top = mid\n else:\n bottom = mid\n\nprint(top)', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndef check(l):\n count = 0\n for L in A:\n count += L // l\n if L % l != 0:\n count += 1\n count -= 1\n return count <= K\n\nbottom, top = 0, max(A)\n\nwhile top - bottom > 1:\n mid = (top + bottom) // 2\n if check(mid):\n top = mid\n else:\n bottom = mid\n\nprint(top)\n']
['Runtime Error', 'Accepted']
['s271159618', 's824476112']
[9004.0, 30628.0]
[27.0, 984.0]
[367, 385]
p02598
u726823037
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import sys\nimport math\ndef Ii():return int(sys.stdin.readline())\ndef Mi():return map(int,sys.stdin.readline().split())\ndef Li():return list(map(int,sys.stdin.readline().split()))\nn,k = Mi()\na = Li()\nsa = sum(a)\nlist.sort(a, reverse=True)\nma = sa//(n+k)+1\ndiv = [0]*n\nfor i in range(n):\n div[i] = math.ceil(a[i]/ma)-1\n \nsd = sum(div)\nif sd > k:\n j = 0\n \n \nlist.sort(div, reverse=True)\nprint(div)\nfor i in range(n):\n a[i] = math.ceil(a[i]/(div[i]+1))\n \nprint(max(a))', 'import sys\nimport numpy as np\nimport math\ndef Ii():return int(sys.stdin.readline())\ndef Mi():return map(int,sys.stdin.readline().split())\ndef Li():return list(map(int,sys.stdin.readline().split()))\nn,k = Mi()\na = np.array(sys.stdin.readline().split(), np.int64)\nmaxa = np.max(a)\nmina = maxa//(k+1)\nwhile maxa > mina+1:\n mid = (mina+maxa)//2\n div = np.sum(np.ceil(a/mid-1))\n if div > k:\n mina = mid\n else:\n maxa = mid\n \nprint(maxa)']
['Wrong Answer', 'Accepted']
['s490356519', 's358199116']
[31084.0, 52644.0]
[310.0, 193.0]
[475, 441]
p02598
u733866054
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k=int(input())\nA=list(map(int,input().split()))\n\nright=10**9\nleft=1\n\nwhile right-left>1 :\n mid=(left+right)//2\n count=0\n for a in A :\n count+=a//mid\n if a%mid==0 :\n count-=1\n if count<=k :\n right=mid\n else :\n left=mid\n\nprint(right)', 'n,k=map(int,input().split())\nA=list(map(int,input().split()))\n\nright=10**9\nleft=0\n\nwhile right-left>1 :\n mid=(left+right)//2\n count=0\n for a in A :\n count+=a//mid\n if a%mid==0 :\n count-=1\n if count<=k :\n right=mid\n else :\n left=mid\n\nprint(right)']
['Runtime Error', 'Accepted']
['s938953086', 's986024792']
[9116.0, 30600.0]
[29.0, 1030.0]
[287, 299]
p02598
u736729525
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\n\nN, K = map(int, input().split())\nA = sorted(list(map(int, input().split())))\n\ndef check(L):\n return sum(math.ceil(a / L)-1 for a in A) <= K\n\nanswer=max(A)\nlo = 1\nhi = answer+1\nwhile lo < hi:\n m = (lo + hi)//2\n ok = check(m)\n if ok: \n answer=min(m, answer)\n hi=m\n else:\n lo=m+1\nprint(answer))\n\n\n\n', 'N, K = map(int, input().split())\nA = sorted(list(map(int, input().split())))\n\ndef check(L):\n return sum(a // L for a in A) <= K\n\nanswer=max(A)\nlo = 1\nhi = answer+1\nwhile lo < hi:\n m = (lo + hi)//2\n ok = check(m)\n if not ok: # \n lo=m+1\n else:\n answer=min(m, answer)\n hi=m\nprint(answer))\n\n\n\n', 'import math\n\nN, K = map(int, input().split())\nA = sorted(list(map(int, input().split())))\n\ndef check(L):\n return sum(math.ceil(a / L)-1 for a in A) <= K\n\nanswer=max(A)\nlo = 1\nhi = answer+1\nwhile lo < hi:\n m = (lo + hi)//2\n ok = check(m)\n if ok: \n answer=min(m, answer)\n hi=m\n else:\n lo=m+1\nprint(answer))\n\n\n\n', 'import math\n\nN, K = map(int, input().split())\nA = sorted(list(map(int, input().split())))\n\ndef check(L):\n return sum(math.ceil(a / L)-1 for a in A) <= K\n\nanswer=max(A)\nlo = 1\nhi = answer+1\nwhile lo < hi:\n m = (lo + hi)//2\n ok = check(m)\n if ok: \n answer=min(m, answer)\n hi=m\n else:\n lo=m+1\nprint(answer)\n\n\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s056774235', 's499082321', 's622269336', 's791783718']
[9044.0, 8952.0, 9020.0, 31004.0]
[23.0, 24.0, 28.0, 1247.0]
[582, 563, 582, 342]
p02598
u744920373
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['def mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n \nN, K = mi()\nA = li()\n \nif K == 0:\n print(max(A))\n exit()\n \nleft = 0\nright = max(A)\n \ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num) - 1\n return cnt\n \nwhile True:\n mid = (left + right) // 2\n if mid == 0:\n mid += 1\n break\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid = right\n break\n left = mid\n else:\n right = mid\n \nif mid == 0 or mid == 1:\n print(mid)\n exit()\n \nright = mid\n \nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n elif tmp == K:\n right = mid\n else:\n if left == mid:\n print(right)\n break\n left = mid\n mid = (left + right) // 2\n if mid == 0:\n print(1)\n break', 'import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n\nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n\ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num)\n \n return cnt\n\n\nwhile True:\n mid = (left + right) // 2\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid += 1\n break\n left = mid\n else:\n right = mid\n\n\nif tmp == K and tmp != count(mid-1):\n print(mid)\n exit()\n\nif mid == 0:\n print(mid)\n exit()\n\nright = mid\nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n if tmp == K:\n right = mid\n else:\n left = mid\n mid = (left + right) // 2', "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n\nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n\ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num)\n \n return cnt\n\n\nwhile True:\n mid = (left + right) // 2\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid += 1\n break\n left = mid\n else:\n right = mid\n\nif mid == 0:\n print(mid)\n exit()\nprint(mid)\n'''\nright = mid\nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n elif tmp == K:\n right = mid\n else:\n if left == mid:\n print(mid+1)\n break\n left = mid\n mid = (left + right) // 2\n'''", 'import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n\nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n\ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num)\n \n return cnt\n\n\nwhile True:\n mid = (left + right) // 2\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid += 1\n break\n left = mid\n else:\n right = mid\n\nif mid == 0:\n print(mid)\n exit()\n\nright = mid\nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n elif tmp == K:\n right = mid\n else:\n if left == mid:\n print(mid+1)\n break\n left = mid\n mid = (left + right) // 2', 'import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n\nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n\ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num)\n \n return cnt\n\n\nwhile True:\n mid = (left + right) // 2\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid += 1\n break\n left = mid\n else:\n right = mid\n\nif mid == 0:\n print(mid)\n exit()\n\nright = mid\nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n elif tmp == K:\n right = mid\n else:\n left = mid\n mid = (left + right) // 2', "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate \nimport math\n\nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n\ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num) - 1\n return cnt\n\nwhile True:\n mid = (left + right) // 2\n if mid == 0:\n mid += 1\n break\n tmp = count(mid)\n if tmp == K:\n break\n elif tmp > K:\n if left == mid:\n mid += 1\n break\n left = mid\n else:\n right = mid\n\nif mid == 0 or mid == 1:\n print(mid)\n exit()\n\nif count(left) == K:\n print('Yeah')\n exit()\nright = mid\n\nwhile True:\n tmp = count(mid)\n if tmp == K and tmp != count(mid-1):\n print(mid)\n break\n elif tmp == K:\n right = mid\n else:\n #if left == mid:\n #print(mid+1)\n #break\n left = mid\n mid = (left + right) // 2\n if mid == 0:\n print(1)\n break", "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for i2 in range(j)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\n#from itertools import accumulate #list(accumulate(A))\nimport math\n \nN, K = mi()\nA = li()\n\nif K == 0:\n print(max(A))\n exit()\n\nleft = 0\nright = max(A)\n \ndef count(num):\n cnt = 0\n for i in range(N):\n cnt += math.ceil(A[i] / num) - 1\n return cnt\n'''\nwhile True:\n mid = (left + right) // 2\n if mid == 0:\n print(1)\n break\n tmp = count(mid)\n if right - left <= 1:\n print(right)\n exit()\n elif tmp > K:\n left = mid\n else:\n right = mid\n'''\n\ndef is_ok(arg):\n if count(arg) <= K:\n return True\n else:\n return False\n \n\ndef meguru_bisect(ng, ok):\n \n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\nprint(meguru_bisect(0, right+1))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s254691566', 's411233961', 's582067128', 's849914793', 's920873614', 's939967339', 's589347636']
[9160.0, 31020.0, 30968.0, 31008.0, 31080.0, 30792.0, 30928.0]
[27.0, 2206.0, 1033.0, 1176.0, 2206.0, 2206.0, 1164.0]
[1369, 1330, 1352, 1334, 1267, 1494, 1611]
p02598
u756195685
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['import math\nN,K = map(int,input().split())\na = list(map(int,input().split()))\ndef is_ok(arg):\n i = 0\n for item in a:\n i += a //arg -1\n return i <=K\n\ndef meguru_bisect(ng, ok):\n \n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n \n', 'import math\nN,K = map(int,input().split())\na = list(map(int,input().split()))\nlow = 0\nhigh = 10**9\nwhile low <= high:\n mid = (low+high)//2\n count = 0\n for item in a:\n count += math.ceil(a/mid)-1\n if count <= K:\n high = mid -1\n else:\n low = mid + 1\nprint(low)\n \n \n', 'import math\nN,K = map(int,input().split())\na = list(map(int,input().split()))\ndef is_ok(arg):\n i = 0\n for item in a:\n i += math.ceil(item /arg) -1\n return i <=K\n\ndef meguru_bisect(ng, ok):\n \n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\n\nprint(meguru_bisect(0,10**9))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s417228343', 's840297742', 's035062874']
[31112.0, 31252.0, 31096.0]
[74.0, 75.0, 985.0]
[616, 306, 655]
p02598
u756388720
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndef isOK(x):\n cnt = 0\n for a in A:\n cnt += (a + x - 1) // x - 1\n return cnt <= K\n\nleft, right = 1, 10 ** 18\nwhile right - left > 1:\n mid = (left + right) // 2\n if isOK(mid):\n left = mid\n else:\n right = mid\nprint(left)\n', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndef isOK(x):\n cnt = 0\n for a in A:\n cnt += (a + x - 1) // x - 1\n return cnt <= K\n\nleft, right = 0, 10 ** 10\nwhile right - left > 1:\n mid = (left + right) // 2\n if isOK(mid):\n right = mid\n else:\n left = mid\nprint(right)\n']
['Wrong Answer', 'Accepted']
['s404900999', 's940586256']
[30876.0, 30696.0]
[2126.0, 931.0]
[327, 328]
p02598
u761062383
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['def check(x, A, K):\n import math\n sumA = 0\n for a in A:\n if a > x:\n sumA += math.ceil(a / x) - 1\n if sumA <= K:\n return True\n else:\n return False\n\n\ndef resolve():\n import bisect\n N, K = [int(i) for i in input().split()]\n A = [int(i) for i in input().split()]\n\n ok = max(A) # maxVal when minimize\n ng = 0 # maxVal when maximize\n while abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if check(mid, A, K):\n ok = mid\n else:\n ng = mid\n print(ok)\n', 'def check(x, A, K):\n import math\n sumA = 0\n for a in A:\n if a > x:\n sumA += math.ceil(a / x) - 1\n if sumA <= K:\n return True\n else:\n return False\n\n\ndef resolve():\n import bisect\n N, K = [int(i) for i in input().split()]\n A = [int(i) for i in input().split()]\n\n ok = max(A) # maxVal when minimize\n ng = 1 # maxVal when maximize\n while abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if check(mid, A, K):\n ok = mid\n else:\n ng = mid\n print(ok)\n', 'def check(x, A, K):\n import math\n sumA = 0\n for a in A:\n if a > x:\n sumA += math.ceil(a / x) - 1\n if sumA <= K:\n return True\n else:\n return False\n\n\ndef resolve():\n _, K = [int(i) for i in input().split()]\n A = [int(i) for i in input().split()]\n\n ok = max(A) # maxVal when minimize\n ng = -1 # maxVal when maximize\n while abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if mid > 0 and check(mid, A, K):\n ok = mid\n else:\n ng = mid\n print(ok)\n\n\nresolve()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s539843302', 's910526493', 's233860734']
[9116.0, 9140.0, 30792.0]
[27.0, 28.0, 990.0]
[547, 547, 554]
p02598
u774539708
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k=map(int,input().split())\nA=list(map(int,input().split()))\nhigh=max(A)\nlow=0\nwhile high-low>1:\n cnt=0\n now=(low+high)//2\n for a in A:\n cnt+=max((a-1)//now,0)\n if cnt>k:\n break\n if cnt>k:\n low=now\n else:\n high=now\n print(cnt,low,high)\nprint(high)', 'n,k=map(int,input().split())\nA=list(map(int,input().split()))\nhigh=max(A)\nlow=0\nwhile high-low>1:\n cnt=0\n now=(low+high)//2\n for a in A:\n cnt+=max((a-1)//now,0)\n if cnt>k:\n break\n if cnt>k:\n low=now\n else:\n high=now\n #print(cnt,low,high)\nprint(high)']
['Wrong Answer', 'Accepted']
['s710264186', 's513395513']
[30740.0, 30828.0]
[1945.0, 1881.0]
[305, 306]
p02598
u796102246
2,000
1,048,576
We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
['n,k = map(int,input().split())\na = list(map(int,input().split()))\nl = 0\nr = 10 ** 9\n\nwhile r-l > 1 :\n m = (l+r)//2 \n b = list(map(lambda x: -(-x//m) - 1 ,a))\n ans = sum(b)\n if ans <= k :\n r = m\n else :\n l = m\n print(l,r)\n\nprint(r)\n\n \n\n', 'n,k = map(int,input().split())\na = list(map(int,input().split()))\nl = 0\nr = 10 ** 9\n\nwhile r-l > 1 :\n m = (l+r)//2 \n b = list(map(lambda x: -(-x//m) - 1 ,a))\n ans = sum(b)\n if ans <= k :\n r = m\n else :\n l = m\n\nprint(r)\n\n \n\n']
['Wrong Answer', 'Accepted']
['s298183177', 's400475488']
[33468.0, 31752.0]
[848.0, 895.0]
[275, 260]