File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ https://www.acmicpc.net/problem/16401
3+ 실버2
4+
5+ # 조건
6+ - 무조건 같은 길이 ㅢ 과자
7+ #문제
8+ - M명의 조카 , N 개의 과자 -> 1명에게 줄 수 잇는 최대길이
9+ - 과자는 길이와 상관 없이 여러조각 나눠질 수 있음+ 하나로 합칠 수 없음 , 길이는 양수
10+ # 유형 :
11+
12+ """
13+ import sys
14+ m ,n = map (int ,sys .stdin .readline ().split ())
15+ snack = list (map (int ,sys .stdin .readline ().split ()))
16+
17+ start = 1 #적어도 길이1로 잘라야 함.
18+ end = max (snack ) #자르는 길이의 최대는 과자 중 제일 긴 놈
19+
20+ answer = 0
21+ while start <= end :
22+ mid = (start + end )// 2
23+
24+ cnt = 0
25+ for x in snack :
26+ if x < mid : #자르려는 단위보다 과자가 작으면 못 자름.
27+ continue
28+ else : #자르려는 단위보다 크면,
29+ cnt += x // mid #그 과자를 해당 단위로 나눈 몫만큼 과자 나옴.
30+
31+ if cnt >= m : #cnt가 너무 많으면 길이를 늘려야 함.
32+ start = mid + 1
33+ answer = mid
34+ else : #cnt가 너무 적으면 길이를 줄여야 함
35+ end = mid - 1
36+
37+ print (answer )
38+
You can’t perform that action at this time.
0 commit comments