6
I made two codes so that an online Judge corrected. They are essentially the same. But the with stdio. h is accepted and the with the iostream is not, because it exceeds the time limit. Why this occurs?
#include <stdio.h>
int tipo[1000000];
int main(){
int qtdrot, qtdtipos, i, x, min;
scanf("%d%d", &qtdrot, &qtdtipos);
for(i=0; i<qtdrot; ++i){
scanf("%d", &x);
tipo[x]++;
}
min=1000000;
for(i=1; i<=qtdtipos; i++){
if(tipo[i]<min)min=tipo[i];
}
printf("%d\n", min);
return 0;
}
The with the iostream:
#include <iostream>
using namespace std;
int tipo[1000000];
int main(){
int qtdrot, qtdtipos, i, min, t;
cin>>qtdrot>>qtdtipos;
for(i=0; i<qtdrot; ++i){
cin>>t;
tipo[t]++;
}
min=1000000;
for(i=1; i<=qtdtipos; i++){
if(tipo[i]<min)min=tipo[i];
}
cout<<min<<endl;
return 0;
}