-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeecrowd_1245.c
68 lines (55 loc) · 1.22 KB
/
beecrowd_1245.c
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
/*
Universidade de Brasília
Departamento de Ciência da Computação
CIC0004 - Algoritmos e Programação de Computadores
Vinicius R. P. Borges
Tópico: Vetores
Objetivo: Solução do problema beecrowd 1245 - Lost Boots
https://judge.beecrowd.com/pt/problems/view/1245
Comandos no Terminal do Linux para compilar e executar o codigo-fonte:
gcc beecrowd_1245.c -o botas
./botas
*/
#include <stdio.h>
#define MAX_M 60
int min(int a, int b){
if(a < b){
return a;
}
else{
return b;
}
}
int solve(int n){
int i,num,ans,pares;
char par;
int botas_esq[MAX_M+1];
int botas_dir[MAX_M+1];
/*inicia todas as posicoes com zero*/
for(i = 0; i <= MAX_M; i++){
botas_esq[i] = 0;
botas_dir[i] = 0;
}
for(i = 0; i < n; i++){
scanf("%d %c\n",&num,&par);
if(par == 'E'){
botas_esq[num]++;
}
else{
botas_dir[num]++;
}
}
pares = 0;
for(i = 30; i <= 60; i++){
pares += min(botas_esq[i],botas_dir[i]);
}
return pares;
}
int main() {
int n,ans;
while(scanf("%d",&n)!=EOF){
ans = solve(n);
printf("%d\n",ans);
}
return 0;
}