-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathpurifier.cpp
51 lines (46 loc) · 1.1 KB
/
purifier.cpp
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
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
string purifier(int X, int Y, vector<int> &h1, vector<int> &m1, vector<int> &h2, vector<int> &m2) {
int free, busy = Y * 10 * 60;
for (int i = 0; i < h1.size(); i++)
busy += (h2[i] * 60 + m2[i]) - (h1[i] * 60 + m1[i]) + 1;
free = Y * 24 * 60 - busy;
return (free >= X * 60) ? "Yes" : "No";
}
int main() {
freopen("purifier.in", "r", stdin);
freopen("output.out", "w", stdout);
int N, k = 1;
cin >> N;
while (N--) {
int X, Y;
cin >> X >> Y;
cin.ignore();
vector<int> h1, m1, h2, m2;
for(int i = 0; i < Y; i++) {
string line, s, token;
getline(cin, line);
if (line == "-")
continue;
istringstream sl(line);
while (sl >> s) {
istringstream ss(s);
getline(ss, token, ':');
h1.push_back(stoi(token));
getline(ss, token, '-');
m1.push_back(stoi(token));
getline(ss, token, ':');
h2.push_back(stoi(token));
ss >> token;
m2.push_back(stoi(token));
}
}
cout << k << ". " << purifier(X, Y, h1, m1, h2, m2) << endl;
k++;
}
return 0;
}