-
Notifications
You must be signed in to change notification settings - Fork 0
/
botas.cpp
40 lines (30 loc) · 903 Bytes
/
botas.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
#include <iostream>
using namespace std;
const int MIN_ROWS = 30;
const int MAX_ROWS = 61;
const int MAX_COLS = 2;
const char LEFT = 'E';
int pairs[MAX_ROWS][MAX_COLS];
int main(){
int N, numberOfPairs = 0;
cin >> N;
for(int row = MIN_ROWS; row < MAX_ROWS; row++){
for(int col = 0; col < MAX_COLS; col++){
pairs[row][col] = 0;
}
}
for(int index = 0; index < N; index++){
int size;
char side;
cin >> size >> side;
if(side == LEFT) pairs[size][0] = pairs[size][0] + 1;
else pairs[size][1] = pairs[size][1] + 1;
int min = pairs[size][0];
if(pairs[size][1] < pairs[size][0]) min = pairs[size][1];
numberOfPairs = numberOfPairs + min;
pairs[size][0] = pairs[size][0] - min;
pairs[size][1] = pairs[size][1] - min;
}
cout << numberOfPairs << endl;
return 0;
}