Skip to content

Instantly share code, notes, and snippets.

@tina1998612
Created November 11, 2016 03:54
Show Gist options
  • Save tina1998612/2975819fd3288d679fdd4e34aca34c27 to your computer and use it in GitHub Desktop.
Save tina1998612/2975819fd3288d679fdd4e34aca34c27 to your computer and use it in GitHub Desktop.
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ll long long
#define N 100000+10
using namespace std;
int n,a[N],cnt,k,fst,maxi;
int main(){
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
maxi=-1;
for(int i=0;i<n;i++) {
cnt=0;
k=0;
while(k<n) {
if(a[(i+k)%n]<=k) cnt++;
k++;
}
if(cnt>maxi){
maxi=cnt;
fst=i;
}
}
cout<<fst+1<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment