Skip to content

Commit

Permalink
02.20
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdls111 committed Feb 20, 2022
1 parent e38d7d8 commit 7fbb76e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 1000/1715.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys, heapq

input = sys.stdin.readline

N = int(input())
q = list(int(input()) for _ in range(N))

heapq.heapify(q)

cnt = 0

while len(q) > 1:
a = heapq.heappop(q)
b = heapq.heappop(q)
heapq.heappush(q, a + b)
cnt += (a + b)

print(cnt)
34 changes: 34 additions & 0 deletions 21000/21202.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys, heapq

input = sys.stdin.readline

N, M = map(int, input().split())
connect = [[] for _ in range(N + 1)]
for _ in range(M):
a, b = map(int, input().split())
# 양방향
connect[a].append(b)
connect[b].append(a)

island_army = [0] + list(int(input()) for _ in range(N))
visited = [False] * (N + 1)

q = []
spanning_army_cnt = island_army[1]
visited[1] = True
for idx in connect[1]:
q.append((island_army[idx], idx))
visited[idx] = True

heapq.heapify(q)

while q and q[0][0] < spanning_army_cnt:
cnt, idx = heapq.heappop(q)
# 연결된 섬들을 대결 후보에 넣기
for i in connect[idx]:
if visited[i] == False:
heapq.heappush(q, (island_army[i], i))
visited[i] = True
spanning_army_cnt += cnt

print(spanning_army_cnt)
10 changes: 10 additions & 0 deletions problem_lists/2022.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

[1477 휴게소 세우기](https://www.acmicpc.net/problem/1477)





### 2월

[5710 전기 요금](https://www.acmicpc.net/problem/5710)[포스팅](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-5710%EC%A0%84%EA%B8%B0-%EC%9A%94%EA%B8%88)

[1202. 보석 도둑](https://www.acmicpc.net/problem/1202) 🎆[설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1202-%EB%B3%B4%EC%84%9D-%EB%8F%84%EB%91%91)
Expand All @@ -43,3 +49,7 @@
[1719 택배](https://www.acmicpc.net/problem/1719) 🎍 [설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1719-%ED%83%9D%EB%B0%B0)

[1405 미친 로봇](https://www.acmicpc.net/problem/1405) 🎀 [설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1405-%EB%AF%B8%EC%B9%9C-%EB%A1%9C%EB%B4%87)

[1715. 카드 정렬하기](https://www.acmicpc.net/problem/1715) 🌸[설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1715-%EC%B9%B4%EB%93%9C-%EC%A0%95%EB%A0%AC%ED%95%98%EA%B8%B0)

[21202. Conquest](https://www.acmicpc.net/problem/21202) 🦄[설명](https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-%ED%8C%8C%EC%9D%B4%EC%8D%AC-21202-Conquest)

0 comments on commit 7fbb76e

Please sign in to comment.