I made two codes for an online judge to correct. They are essentially the same. But the stdio.h is accepted and the with the iostream does not, because it exceeds the time limit. Why does this occur?
#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;
}
O with 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;
}