-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKattis_resturant.cpp
More file actions
49 lines (41 loc) · 1.2 KB
/
Kattis_resturant.cpp
File metadata and controls
49 lines (41 loc) · 1.2 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
#include <bits/stdc++.h> // here we have all the STL we need, including istringstream and ostringstream
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
using namespace std;
#define min(a,b) (a < b) ? (a) : (b)
#define max(a,b) (a > b) ? (a) : (b)
#define vii vector<pair<int,int>>
int main() {
FAST
int N;
string word;
int m;
while (cin >> N && N) {
int p1 = 0, p2 = 0;
while (N--) {
cin >> word >> m;
if (word[0] == 'D') {
p2 += m;
cout << "DROP 2 " << m << endl;
}
else {
if (p1 >= m) {
p1 -= m;
cout << "TAKE 1 " << m << endl;
}
else {
if (p1 > 0) {
cout << "TAKE 1 " << p1 << endl;
m -= p1;
}
cout << "MOVE 2->1 " << p2 << endl;
p1 = p2;
p2 = 0;
cout << "TAKE 1 " << m << endl;
p1 -= m;
}
}
}
cout << endl;
}
}