Skip to content

Commit 3eddd3e

Browse files
committed
[ADD] BOJ 15577 Prosjek
- 자료구조
1 parent 216f9f8 commit 3eddd3e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

acmicpc.net/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@
743743
| 49 | [평행선](https://www.acmicpc.net/problem/2358) | [cpp](source/2358.cpp) | 50 | [괄호 끼워넣기](https://www.acmicpc.net/problem/11899) | [cpp](source/11899.cpp) |
744744
| 51 | [천재 수학자 성필](https://www.acmicpc.net/problem/15815) | [cpp](source/15815.cpp) | 52 | [파일 정리](https://www.acmicpc.net/problem/20291) | [cpp](source/20291.cpp) |
745745
| 53 | [Olympiad Pizza](https://www.acmicpc.net/problem/15235) | [cpp](source/15235.cpp) | 54 | [암기왕](https://www.acmicpc.net/problem/2776) | [cpp](source/2776.cpp) |
746+
| 55 | [Prosjek](https://www.acmicpc.net/problem/15577) | [cpp](source/15577.cpp) | | | |
746747

747748
</details>
748749

acmicpc.net/source/15577.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// 15577. Prosjek
2+
// 2022.03.14
3+
// 자료구조
4+
#include<iostream>
5+
#include<queue>
6+
7+
using namespace std;
8+
9+
int main()
10+
{
11+
priority_queue<float, vector<float>, greater<float>> pq;
12+
int n;
13+
cin >> n;
14+
for (int i = 0; i < n; i++)
15+
{
16+
float k;
17+
cin >> k;
18+
pq.push(k);
19+
}
20+
21+
while (!pq.empty())
22+
{
23+
if (pq.size() == 1)
24+
{
25+
break;
26+
}
27+
float a = pq.top();
28+
pq.pop();
29+
float b = pq.top();
30+
pq.pop();
31+
32+
pq.push((a + b) / 2.0f);
33+
}
34+
35+
cout << fixed;
36+
cout.precision(6);
37+
cout << (float)pq.top() << endl;
38+
return 0;
39+
}

0 commit comments

Comments
 (0)