일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- expo
- Android
- itertools
- 11057
- 안드로이드
- 파이썬
- 11054
- 백준
- 홈화면
- 뒤로가기
- 11기
- LCS
- Combination
- 코테
- 11053
- Kotlin
- 1260
- Python
- lcm
- 1182
- 괄호
- 순열
- 앱
- permutation
- 6603
- 최소공배수
- 9095
- 매일11시
- 코틀린
- 나머지
Archives
- Today
- Total
목록13975 (1)
황소개발자
백준 13975 파이썬 python : 파일 합치기 3 @@황소처럼 우직하게@@ 문제의 본질
푸는 방법은 다음과 같다 1. 파일들 중에서 제일 작은 두개를 뽑는다. 2. 합친다 3. 합친걸 다시 파일들에 둔다. 반복한다 이 때 구현은 minq 를 사용하는 것이 효율적이다. import sys input = sys.stdin.readline import heapq t = int(input()) for _ in range(t): n = int(input()) lst = list(map(int, input().split())) ans = 0 q = [] for i in lst: heapq.heappush(q, i) while len(q) > 1: a = heapq.heappop(q) b = heapq.heappop(q) ans += a + b heapq.heappush(q, a + b) print(a..
백준 문제 풀이
2020. 3. 26. 01:31