Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Tags
- 딕셔너리
- level2
- MYSQL
- python
- level3
- 가상메모리
- 백준
- 코딩테스트
- 수학
- BOJ
- 스택
- 다익스트라
- dict
- level1
- 프로그래머스
- 브루트포스
- N과M
- level0
- programmers
- BFS
- 재귀
- 파이썬
- 그리디
- DP
- 가상메모리 관리
- 다이나믹 프로그래밍
- 힙
- 운영체제
- dfs
- 구현
Archives
- Today
- Total
동캄의 코딩도장
백준 2805 [나무 자르기] 파이썬 본문
https://www.acmicpc.net/problem/2805
#백준 2805
import sys
import math
input = sys.stdin.readline
answer = 0
N, M = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
S = sum(lst)
for i in range(len(lst)):
answer = max(answer, math.floor((S-M)//(len(lst)-i)))
S -= lst[i]
print(answer)
list를 정렬하고, 앞에서부터 하나씩 빼면서 필요한 높이의 최대값을 구한다.
'코테 > BOJ' 카테고리의 다른 글
백준 7576 [토마토] 파이썬 (0) | 2022.03.21 |
---|---|
백준 11866 [요세푸스 문제 0] 파이썬 (0) | 2022.03.07 |
백준 1966 [프린터] 파이썬 (0) | 2022.03.07 |
백준 1874 [스택 수열] 파이썬 (0) | 2022.03.07 |
백준 10816 [숫자 카드 2] 파이썬 (0) | 2022.02.15 |