Skip to content

Commit d35172c

Browse files
committed
[Gold V] Title: 콘센트, Time: 0 ms, Memory: 2064 KB -BaekjoonHub
1 parent 0b6df78 commit d35172c

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# [Gold V] 콘센트 - 23843
2+
3+
[문제 링크](https://www.acmicpc.net/problem/23843)
4+
5+
### 성능 요약
6+
7+
메모리: 2064 KB, 시간: 0 ms
8+
9+
### 분류
10+
11+
자료 구조, 그리디 알고리즘, 정렬, 우선순위 큐
12+
13+
### 제출 일자
14+
15+
2026년 2월 24일 21:38:30
16+
17+
### 문제 설명
18+
19+
<p>광재는 전자기기 대여사업을 시작했다. 퇴근하기 전에 다음날 손님들에게 빌려줄 <em>N</em>개의 전자기기를 충전하려 한다. 사용 가능한 콘센트는 <em>M</em>개가 있고, 성능은 모두 동일하다.</p>
20+
21+
<p>전자기기들은 한 번에 하나의 콘센트에서만 충전이 가능하고, 충전에 필요한 시간은 2<em><sup>k</sup></em>(0 ≤ <em>k</em> ≤ 15, <em>k</em>는 정수)<em><sup> </sup></em>형태이다.</p>
22+
23+
<p>광재의 빠른 퇴근을 위해 모든 전자기기를 충전하기 위한 최소 시간이 얼마인지 알려주자.</p>
24+
25+
### 입력
26+
27+
<p>첫째 줄에 전자기기의 개수 <em>N</em>과 콘센트의 개수 <em>M</em>이 주어진다. (1 ≤ <em>N </em>≤ 10,000, 1 ≤ <em>M</em> ≤ 10)</p>
28+
29+
<p>둘째 줄에 충전에 필요한 시간 <em>t<sub>i</sub></em>를 나타내는 <em>N</em>개의 정수가 주어진다. (2<sup>0 </sup>​≤ <em>t</em><sub><em>i</em> </sub>≤ 2<sup>15</sup>, t<sub>i </sub>= 2<sup>k </sup>(0 ≤ <em>k</em> ≤ 15, <em>k</em>는 정수))</p>
30+
31+
### 출력
32+
33+
<p>충전에 필요한 최소 시간을 출력한다.</p>
34+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include<iostream>
2+
#include<queue>
3+
#include<algorithm>
4+
using namespace std;
5+
6+
const int N = 1e4;
7+
int n, m;
8+
int arr[N];
9+
10+
int main() {
11+
ios::sync_with_stdio(0);
12+
cin.tie(0);
13+
14+
cin >> n >> m;
15+
for (int i = 0; i < n; ++i) cin >> arr[i];
16+
sort(arr, arr + n, greater<int>());
17+
18+
priority_queue<int, vector<int>, greater<int>> pq;
19+
while (m--) pq.push(0);
20+
21+
for (int i = 0; i < n; ++i) {
22+
int d = arr[i];
23+
int c = pq.top(); pq.pop();
24+
pq.push(c + d);
25+
}
26+
27+
while (1) {
28+
int c = pq.top(); pq.pop();
29+
if (pq.empty()) {
30+
cout << c;
31+
break;
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)