#include <iostream>
using namespace std;
int maxarray(const int a[], int first, int last) {
if (first+1 == last) {
return a[first];
}
int mid = first + (last - first) / 2;
int left = maxarray(a, first, mid);
int right = maxarray(a, mid, last);
return left > right ? left : right;
}
int main() {
int arr[10] = {1,20,3,41,5,6,7,8,99,0};
cout << maxarray(arr, 0, 10) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYXhhcnJheShjb25zdCBpbnQgYVtdLCBpbnQgZmlyc3QsIGludCBsYXN0KSB7CglpZiAoZmlyc3QrMSA9PSBsYXN0KSB7CgkgICAgcmV0dXJuIGFbZmlyc3RdOwoJfQoJaW50IG1pZCA9IGZpcnN0ICsgKGxhc3QgLSBmaXJzdCkgLyAyOwoJaW50IGxlZnQgPSBtYXhhcnJheShhLCBmaXJzdCwgbWlkKTsKCWludCByaWdodCA9IG1heGFycmF5KGEsIG1pZCwgbGFzdCk7CglyZXR1cm4gbGVmdCA+IHJpZ2h0ID8gbGVmdCA6IHJpZ2h0Owp9CgppbnQgbWFpbigpIHsKCWludCBhcnJbMTBdID0gezEsMjAsMyw0MSw1LDYsNyw4LDk5LDB9OwoJY291dCA8PCBtYXhhcnJheShhcnIsIDAsIDEwKSA8PCBlbmRsOwoJcmV0dXJuIDA7Cn0=