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 |
Tags
- 프로그래머스 푸드 파이트 대회
- 문자형 배열
- LAN의 분류
- 값/참조/주소에 의한 전달
- const l-value참조자
- c언어 괄호검사
- 알고리즘 조건
- string유형
- 백준 파이썬
- C언어 계산기 프로그램
- getline()함수
- 주기억장치
- r-value참조자
- IPv4 주소체계
- 유형 변환
- l-value참조자
- 회전 및 자리 이동 연산
- 괄호 검사 프로그램
- 운영체제 기능
- C언어 덱
- 논리 연산
- 프로그래머스 배열만들기4
- C언어 스택 연산
- 원형 연결 구조 연결된 큐
- const화
- auto 키워드
- 입출력 관리자
- 네트워크 결합
- 문제해결 단계
- 범위 기반 for문
Archives
- Today
- Total
chyam
[백준] 15903,python - 카드 합체 놀이 본문

https://www.acmicpc.net/problem/15903
import sys,heapq
input= sys.stdin.readline
n, m = map(int,input().split())
heap = list(map(int,input().split()))
heapq.heapify(heap)
for i in range(m):
x = heapq.heappop(heap) # 가장 작은수
y = heapq.heappop(heap) # 다음으로 작은수
heapq.heappush(heap,x+y) # 합을 두번 추가해줌
heapq.heappush(heap,x+y)
print(sum(heap))'백준' 카테고리의 다른 글
| [백준] 10815번,python - 숫자 카드 (0) | 2025.09.12 |
|---|---|
| [백준] 1377번, python - 버블 소트 (0) | 2025.09.11 |
| [백준] 5464번,python - 주차장 (0) | 2025.09.09 |
| [백준] - 1874번, python - 스택 수열 (0) | 2025.09.08 |
| [백준] 12891번, python - DAN 비밀번호 (0) | 2025.09.07 |
