Skip to content

Instantly share code, notes, and snippets.

@zuigon
Created November 19, 2013 22:25
Show Gist options
  • Save zuigon/7553686 to your computer and use it in GitHub Desktop.
Save zuigon/7553686 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(){
int m[25]={0}, // matrica sati, sve nule
n, i, j, ta, tb, mmax=1;
scanf("%d", &n);
for(i=0; i<n ; ++i){
scanf("%d%d", &ta, &tb);
for(j=ta; j<=tb; ++j)
m[j]++;
}
for(i=0; i<25; ++i)
if(m[i]>mmax)
mmax=m[i];
i=0;
while(m[i]!=mmax)
i++;
// sad je i postao prvi 'naj' sat
// ispisuje prvi interval gdje je bilo najvise ljudi, ne sve
printf("Najvise ljudi: %d, od: %d, do: ", mmax, i);
while(m[i]==mmax)
i++;
printf("%d (ukljucujuci)\n", i-1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment