forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotamused.cpp
57 lines (47 loc) · 1.23 KB
/
notamused.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
52
53
54
55
56
57
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
string s;
int count = 1;
map<string, vector<int>> times;
bool first = true;
while(cin >> s) {
// If the park is opening
if(s == "OPEN") {
if(first) {
first = false;
}
else {
cout << endl;
}
cout << "Day " << count << endl;
count++;
continue;
}
// If the park is closing
if(s == "CLOSE") {
// Print each customer
for(auto i : times) {
double total = 0;
for(int j = 0; j < i.second.size(); j += 2) {
total += i.second[j+1] - i.second[j];
}
total /= 10;
cout << fixed;
cout.precision(2);
// Calculate times here, print
cout << i.first << " $" << total << endl;
}
// Reset the map
times.clear();
continue;
}
// Read in the person's data
string name;
int time;
cin >> name >> time;
times[name].push_back(time);
}
}