[백준] 2822 점수 계산
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
return a.first > b.first;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
vector<pair<int, int>> score;
for (int i = 0; i < 8; ++i) {
int input;
cin >> input;
score.push_back({ input, i+1 });
}
sort(score.begin(), score.end(), cmp);
int sum = 0;
vector<int> num;
for (int i = 0; i < 5; ++i) {
sum += score[i].first;
num.push_back(score[i].second);
}
cout << sum << "\n";
sort(num.begin(), num.end());
for (int i = 0; i < 5; ++i) {
cout << num[i] << " ";
}
return 0;
}