This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <queue> | |
#include <vector> | |
using namespace std; | |
int main () { | |
priority_queue<pair<int, int> > a; | |
priority_queue<int,vector<int>,greater<int> > b; | |
for (int i = 1; i <= 8; i++) { | |
int temp; | |
scanf("%d", &temp); | |
a.push(make_pair(temp, i)); | |
} | |
int result = 0; | |
for (int i = 0; i < 5; i++) { | |
int grade = a.top().first; | |
int idx = a.top().second; | |
b.push(idx); | |
a.pop(); | |
result += grade; | |
} | |
printf("%d\n", result); | |
for(int i = 0; i < 5; i++) { | |
printf("%d ", b.top()); | |
b.pop(); | |
} | |
} |
'IT > 알고리즘' 카테고리의 다른 글
BOJ 백준온라인져지 1389 케빈 베이컨의 6단계 법칙 풀이 (0) | 2018.01.30 |
---|---|
BOJ 백준온라인져지 11376 열혈강호 2 풀이 (0) | 2018.01.27 |
BOJ 백준온라인져지 11375 열혈강호 풀이 (0) | 2018.01.23 |
BOJ 백준온라인져지 14502 연구소 풀이 (0) | 2018.01.14 |
BOJ 백준온라인져지 4485 녹색 옷 입은 애가 젤다지? 풀이 (0) | 2018.01.13 |