Skip to content

Commit c176f16

Browse files
authored
Merge pull request #138 from YoonYn9915/main
YoonYn9915 / 2월 1주차 / 3문제
2 parents 7a6e4e3 + 45e2e8e commit c176f16

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sys
2+
import heapq
3+
4+
N, K = map(int, sys.stdin.readline().split())
5+
jewels = []
6+
for _ in range(N):
7+
heapq.heappush(jewels, list(map(int, sys.stdin.readline().split())))
8+
bags = []
9+
for _ in range(K):
10+
bags.append(int(sys.stdin.readline()))
11+
bags.sort()
12+
13+
answer = 0
14+
tmp_jew = []
15+
for bag in bags:
16+
while jewels and bag >= jewels[0][0]:
17+
heapq.heappush(tmp_jew, -heapq.heappop(jewels)[1])
18+
if tmp_jew:
19+
answer -= heapq.heappop(tmp_jew)
20+
elif not jewels:
21+
break
22+
print(answer)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import heapq
2+
3+
population, centi_height, limit = map(int, input().split())
4+
5+
arr_heights = []
6+
max_height = -1
7+
8+
for _ in range(population):
9+
heapq.heappush(arr_heights, -(int(input())))
10+
11+
if centi_height > -arr_heights[0]:
12+
print("YES")
13+
print(0)
14+
exit(0)
15+
16+
for i in range(limit):
17+
# 키가 가장 큰 거인 선택
18+
max_height = -(heapq.heappop(arr_heights))
19+
20+
# 가장 큰 거인의 키가 1인 경우 뿅망치 무효화.
21+
if max_height == 1:
22+
heapq.heappush(arr_heights, -(max_height))
23+
else:
24+
heapq.heappush(arr_heights, -(max_height//2))
25+
26+
max_height = -(heapq.heappop(arr_heights))
27+
28+
if centi_height > max_height:
29+
print("YES")
30+
print(i+1)
31+
exit(0)
32+
heapq.heappush(arr_heights, -max_height)
33+
34+
35+
print("NO")
36+
print(max_height)
37+
38+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
n = int(input())
2+
rope = []
3+
4+
for i in range(n):
5+
rope.append(int(input()))
6+
rope.sort(reverse=True)
7+
8+
for i in range(n):
9+
rope[i] = rope[i] * (i+1)
10+
11+
print(max(rope))

0 commit comments

Comments
 (0)