We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4d92084 + 8946d75 commit 52c3467Copy full SHA for 52c3467
[Week18 - Search]/이현동/2343.py
@@ -0,0 +1,30 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
5
+N, M = map(int, input().split())
6
+arr = list(map(int, input().split()))
7
8
9
+l = max(arr)
10
+r = 1000000001
11
+mid = 0
12
13
+while l <= r:
14
+ mid = (l+r)//2
15
+ cnt, tot = 0, 0
16
+ for i in range(N):
17
+ if(arr[i] + tot > mid):
18
+ tot = 0
19
+ cnt+=1
20
+ tot += arr[i]
21
22
+ if tot != 0:
23
24
25
+ if cnt > M:
26
+ l = mid + 1
27
+ else:
28
+ r = mid - 1
29
30
+print(l)
0 commit comments