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 | 31 |
Tags
- re_lunchu
- cs공부
- GAN
- JavaScript
- boj
- 자바
- 오블완
- Algorithm
- 프로그래머스
- 티스토리챌린지
- 딥러닝
- Baekjoon
- programmers
- 소프티어
- 백준
- 스마트팩토리
- Java
- 토이프로젝트
- 자바스크립트
- 현대자동차
- 알고리즘
- softeer
- cim
- alogorithm
- heapq
- Python
- 탐욕법
- 파이썬
- 현대
- 힙큐
Archives
- Today
- Total
eaz_coding
[Baekjoon] 2805 나무 자르기 본문
문제
https://www.acmicpc.net/problem/2805
풀이
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
trees = list(map(int, input().split()))
u, l = max(trees), 1
answer = 0
while l < u:
mid = (u+l) // 2
s = 0
for i in range(n):
if trees[i] - mid > 0:
s += (trees[i] - mid)
if s >= m:
break
if s >= m:
if answer < mid:
answer = mid
l = mid+1
else:
u = mid
print(answer)
'eaz_algorithm' 카테고리의 다른 글
[Baekjoon] 1300 K번째 수 (0) | 2024.11.16 |
---|---|
[Baekjoon] 1904번 01타일 (0) | 2024.11.15 |
[Baekjoon] 12865 평범한 배낭 (0) | 2024.11.13 |
[Baekjoon] 9251 LCS (0) | 2024.11.12 |
[Programmers] (0) | 2024.11.11 |