알고리즘/백준(BOJ)
백준 - 17509 And the Winner Is... Ourselves!
시나모온
2020. 7. 29. 16:52
문제 링크입니다 : https://www.acmicpc.net/problem/17509
17509번: And the Winner Is... Ourselves!
11 lines are given as the input. The $i$-th line contains two space-separated integers, $D_i$ and $V_i$, where $D_i$ is the amount of minutes required to solve the $i$-th problem, and $V_i$ is the number of incorrect verdicts on the $i$-th problem. For eac
www.acmicpc.net
그리디
#include <iostream>
#include <vector>
#include <algorithm>
#define PROB_NUM 11
using namespace std;
int main() {
vector<pair<int, int>> problems(PROB_NUM);
for(int i = 0; i < PROB_NUM; i++) {
cin >> problems[i].first >> problems[i].second;
}
sort(problems.begin(), problems.end());
int penalty = 0;
int time = 0;
for(int i = 0; i < PROB_NUM; i++) {
time += problems[i].first;
penalty += (time + 20 * problems[i].second);
}
cout << penalty;
return 0;
}
개발 환경 : vscode
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~