Skip to content

Commit 52c3467

Browse files
authored
Merge pull request #133 from LEEHYUNDONG/main
220817/이현동
2 parents 4d92084 + 8946d75 commit 52c3467

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

[Week18 - Search]/이현동/2343.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
cnt+=1
24+
25+
if cnt > M:
26+
l = mid + 1
27+
else:
28+
r = mid - 1
29+
30+
print(l)

0 commit comments

Comments
 (0)