-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_13904.cpp
More file actions
49 lines (37 loc) · 858 Bytes
/
BOJ_13904.cpp
File metadata and controls
49 lines (37 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<int, int>& a, const pair<int, int>& b)
{
return a.second > b.second;
}
int main() {
int N;
cin >> N;
int total = 0;
vector<pair<int, int>> hw;
int did[1000] = { 0 };
int time, point;
for (int i = 0; i < N; i++) {
cin >> time >> point;
hw.push_back(make_pair(time, point));
}
// 과제 배당 점수 순으로 정렬
sort(hw.begin(), hw.end(), cmp);
// 배점이 큰 과제부터 채워나가되 그 과제를 최대한 늦게 수행(n일까지면 1~n일 중 할 수 있는 가장 마지막날에)
for (int i = 0; i < N; i++) {
int myTime = hw[i].first;
int myPoint = hw[i].second;
int pointer = myTime - 1;
while (pointer >= 0) {
if (did[pointer] == 0) {
did[pointer] = myPoint;
break;
}
pointer--;
}
}
for (int j = 0; j < 1000; j++) {
total += did[j];
}
cout << total << endl;
}