Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#define DEBUG
- #include<stdio.h>
- int* find_max(int* a, int n)
- {
- if(n == 1)return a;
- if(n == 2)
- {
- if(a[0]>a[1])return a;
- return a+1;
- }
- int mid = n/2;
- if(a[mid] - a[mid-1] < 0) return find_max(a,n/2);
- return find_max(a+n/2, n-n/2);
- }
- int main()
- {
- #ifdef DEBUG
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- freopen("err.txt","w",stderr);
- #endif
- int n;
- scanf("%d",&n);
- int a[10000];
- int i;
- for(i=0;i<n;i++)scanf("%d",&a[i]);
- int *iMax = find_max(a,n);
- printf("%d\n%d\n",iMax-a+1,*iMax);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement