fork(6) download
  1. #include<stdio.h>
  2.  
  3. int main(){
  4. int D[61], E[61];
  5. int i,N,M,r;
  6. char L;
  7.  
  8. //enquanto existem valores sendo fornecidos
  9. while(scanf("%d", &N)>=0){
  10. r=0;
  11. //preenche os dois vetores com zeros
  12. for(i=0; i<61; i++){
  13. D[i] = 0;
  14. E[i] = 0;
  15. }
  16. //enquanto tiver botas (N > 0) faça
  17. while(N--){
  18. scanf("%d %c", &M, &L);
  19. if(L=='E') {
  20. E[M]++;
  21. } else {
  22. D[M]++;
  23. }
  24. if(E[M] && D[M]){
  25. E[M]--;
  26. D[M]--;
  27. r++;
  28. }
  29. }
  30. printf("%d\n", r);
  31. }
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3464KB
stdin
4
40 D
41 E
41 D
40 E
6
38 E
39 E
40 D
38 D
40 D
37 E
stdout
2
1