-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1246.cpp
58 lines (52 loc) · 1.5 KB
/
1246.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 <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main(){
ull c, n, p, q;
string carac;
vector <ull> vet(1001);
while(cin >> c >> n){
ull fatura = 0;
vet.assign(1001, 0);
for(ull i=0; i< n; i++){
cin >> carac;
if(carac == "C"){
cin >> p >> q;
ull cont = 0;
bool paga = false;
for(ull j = 0; j< c; j++){
//cout<<j<<endl;
if(vet[j]==0) cont++;
else cont = 0;
if (cont == q){
//cout<<cont <<" "<< j <<endl;
for(ull k=j-cont+1; k<=j; k++){
vet[k] = p;
paga = true;
}
break;
}
}
if(paga) fatura ++;
}
else{
cin >> p;
bool flag = false;
for(ull j=0; j< c; j++){
if(vet[j]==p){
vet[j] = 0;
flag = true;
}
else if (vet[j]!=0 && flag){
break;
}
}
}
/*for(ull j=0; j< c; j++){
cout << vet[j] << " ";
}
cout << endl;*/
}
cout<< fatura*10 << endl;
}
}