-
-
Save akhal3d96/7bcebd8cc5f1354d243b to your computer and use it in GitHub Desktop.
Solution of Div312#2 Problem B http://codeforces.com/contest/558/problem/B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main() | |
{ | |
int times[1000001],indst[1000001],inden[1000001],n,i,f,maxn,max; | |
maxn=-1; | |
scanf("%d",&n); | |
memset(times, 0, 1000001*sizeof(int)); | |
for(i=0;i<n;i++) | |
{ | |
scanf("%d",&f); | |
times[f]+=1; | |
if(times[f]==1) | |
indst[f]=i+1; | |
inden[f]=i+1; | |
if(times[f]>maxn) | |
{ | |
max=f; | |
maxn=times[f]; | |
} | |
else if(times[f]==maxn) | |
{ | |
if((inden[max]-indst[max])>(inden[f]-indst[f])) | |
max=f; | |
} | |
} | |
printf("%d %d",indst[max],inden[max]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment