-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path26-134.cpp
More file actions
55 lines (46 loc) · 1.32 KB
/
26-134.cpp
File metadata and controls
55 lines (46 loc) · 1.32 KB
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
#include <bits/stdc++.h>
using namespace std;
int main() {
fstream f;
f.open("26-134.txt");
vector<pair<int, int>> G, W, M;
int t = 0, kg = 0, kw = 0, km = 0, vremya = 0, n = 0, k;
f >> k >> t;
char z;
for (int i = 0, x, y; i < k; i++) {
f >> x >> y >> z;
if (z == 'G') G.emplace_back(x, y);
if (z == 'W') W.emplace_back(x, y);
if (z == 'M') M.emplace_back(x, y);
}
sort(G.begin(), G.end());
sort(W.begin(), W.end());
sort(M.begin(), M.end());
char people;
while (true) {
int r = min(G[0].first, min(W[0].first, M[0].first));
if (vremya < r) vremya = r;
if (G[0].first <= vremya) {
vremya += G[0].second;
++kg;
n++;
people = 'G';
G.erase(G.begin());
} else if (W[0].first <= vremya) {
vremya += W[0].second;
++kw;
n++;
people = 'W';
W.erase(W.begin());
} else if (M[0].first <= vremya) {
vremya += M[0].second;
++km;
n++;
people = 'M';
M.erase(M.begin());
}
if (vremya >= t) break;
}
cout << n << " " << people << endl;
cout << kg << " " << kw << " " << km;
}