-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy patharranging_tasks.cpp
More file actions
45 lines (33 loc) · 743 Bytes
/
Copy patharranging_tasks.cpp
File metadata and controls
45 lines (33 loc) · 743 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
// https://www.urionlinejudge.com.br/judge/en/problems/view/1704
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct task {
int V, T;
};
bool sortByTime(task &ta1, task &ta2) {
if (ta1.V >= ta2.V) return true;
else if (ta1.V < ta2.V) return false;
else return ta1.T <= ta2.T;
}
int main() {
int N, H, V, T;
while (cin >> N >> H) {
vector<task> tasks;
while (N--) {
cin >> V >> T;
task ta;
ta.V = V;
ta.T = T;
tasks.push_back(ta);
}
sort(tasks.begin(), tasks.end(), sortByTime);
int value = 0;
for (int i = 0; i < H && i < 10; i++) {
if (tasks[i].T <= H) value += tasks[i].V;
}
cout << value << endl;
}
return 0;
}