-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1361.cpp
More file actions
63 lines (49 loc) · 1.17 KB
/
1361.cpp
File metadata and controls
63 lines (49 loc) · 1.17 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
56
57
58
59
60
61
62
63
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
bool comp(int a, int b) {
return a > b;
}
int calculaAndares(map<int, char> &pr){
int aux = 0;
char cor = 'N';
for(auto it = pr.rbegin(); it != pr.rend(); ++it) {
if(cor == 'N') {
if(it->second == 'V') cor = 'V';
else cor = 'A';
aux++;
} else {
if(cor == 'A'){
if(it->second == 'V') {
cor = 'V';
aux++;
}
} else {
if(it->second == 'A') {
cor = 'A';
aux++;
}
}
}
}
return aux;
}
int main() {
int num_testes, andares, andar;
map<int, char> predio;
cin >> num_testes;
for(int i=0; i<num_testes; i++) {
cin >> andares;
for(int j=0; j<andares; j++) {
cin >> andar;
if(andar < 0) predio[abs(andar)] = 'V';
else predio[andar] = 'A';
}
int res = calculaAndares(predio);
cout << res << endl;
predio.clear();
}
return 0;
}