-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13904.cpp
More file actions
61 lines (44 loc) · 866 Bytes
/
13904.cpp
File metadata and controls
61 lines (44 loc) · 866 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
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;
vector<pair<int, int>>v;
vector<int>val[101];
int res;
int main() {
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
int N;
cin >> N;
while (N--) {
int a, b;
cin >> a >> b;
v.push_back({ b,a });//점수 기준으로 내림차순
}
sort(v.begin(), v.end(),greater<pair<int,int>>());
for (int i = 0;i < v.size();i++) {
//cout << v[i].first << ' ' << v[i].second << "\n";
int idx = 0;
idx = v[i].second;//두번째 값이 날짜
if (val[idx].empty())
{
val[idx].push_back(v[i].first);
res += v[i].first;
}
else {
while ((idx-1) > 0) {
idx--;
if (val[idx].empty()) {
val[idx].push_back(v[i].first);
res += v[i].first;
break;
}
}
}
}
cout << res << "\n";
return 0;
}