-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1419.cpp
More file actions
84 lines (63 loc) · 1.91 KB
/
1419.cpp
File metadata and controls
84 lines (63 loc) · 1.91 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <map>
using namespace std;
char calculaPontosAdicionais(int auxMark, int auxLeti){
if(auxMark > 0 && auxLeti > 0) {
if(auxMark < auxLeti) return 'M';
else if (auxLeti < auxMark) return 'L';
else return 'T';
} else if (auxMark > 0) {
return 'M';
} else if (auxLeti > 0) {
return 'L';
} else {
return 'N';
}
}
int calculaPontos(map<int, int> pontos){
int total = 0;
for(auto p : pontos){
total += (p.first * p.second);
}
return total;
}
int main(){
int rodadas;
int pontoM, pontoL;
map<int, int> pontosMark;
map<int, int> pontosLeti;
while(true){
map<int, int> auxiliar1;
map<int, int> auxiliar2;
int auxM = 0, auxL = 0;
cin >> rodadas;
if(rodadas == 0) break;
for(int i=0; i<rodadas; i++){
cin >> pontoM;
pontosMark[pontoM]++;
auxiliar1[i] = pontoM;
if(pontosMark[pontoM] == 3 && auxM == 0){
if(auxiliar1[i] == auxiliar1[i-1] && auxiliar1[i-1] == auxiliar1[i-2]) auxM = i;
}
}
for(int i=0; i<rodadas; i++){
cin >> pontoL;
pontosLeti[pontoL]++;
auxiliar2[i] = pontoL;
if(pontosLeti[pontoL] == 3 && auxL == 0){
if(auxiliar2[i] == auxiliar2[i-1] && auxiliar2[i-1] == auxiliar2[i-2]) auxL = i;
}
}
int totalLeti = calculaPontos(pontosLeti);
int totalMark = calculaPontos(pontosMark);
char v = calculaPontosAdicionais(auxM, auxL);
if(v == 'M') totalMark += 30;
if(v == 'L') totalLeti += 30;
if(totalMark > totalLeti) cout << "M" << endl;
if(totalLeti > totalMark) cout << "L" << endl;
if(totalLeti == totalMark) cout << "T" << endl;
pontosMark.clear();
pontosLeti.clear();
}
return 0;
}