You are helping a geologist friend investigate an area with mountain lakes. A recent heavy rainfall has flooded these lakes and their water levels have reached the highest possible point. Your friend is interested to know the maximum depth in the deepest part of these lakes.
We simplify the problem in 2-D dimensions. The whole landscape can be divided into small blocks and described by an array A of length N. Each element of A is the altitude of the rock floor of a block (i.e. the height of this block when there is no water at all). After the rainfall, all the low-lying areas (i.e. blocks that have higher blocks on both sides) are holding as much water as possible. You would like to know the maximum depth of water after this entire area is flooded. You can assume that the altitude outside this area is zero and the outside area can accommodate infinite amount of water.
For example, consider array A such that:
A[0] = 1 A[1] = 3 A[2] = 2 A[3] = 1 A[4] = 2 A[5] = 1 A[6] = 5 A[7] = 3 A[8] = 3 A[9] = 4 A[10] = 2The following picture illustrates the landscape after it has flooded:
The gray area is the rock floor described by the array A above and the blue area with dashed lines represents the water filling the low-lying areas with maximum possible volume. Thus, blocks 3 and 5 have a water depth of 2 while blocks 2, 4, 7 and 8 have a water depth of 1. Therefore, the maximum water depth of this area is 2.
Write a function:
int solution(int A[], int N);
that, given a non-empty array A consisting of N integers, returns the maximum depth of water.
Given array A shown above, the function should return 2, as explained above.
For the following array:
A[0] = 5 A[1] = 8the function should return 0, because this landscape cannot hold any water.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..100,000];
- each element of array A is an integer within the range [1..100,000,000].
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
}
left=i;
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
}
if(A[i]>A[i+1]){
left=i;
}
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1])
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
if(A[right]<A[i+1]){
right=i+1;
}
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=(A[left]<A[i+1])?A[left]:A[i+1];
int val=right-min
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int left=0;
int min=-1;
int right=0;
int ret=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=(A[left]<A[i+1])?A[left]:A[i+1];
int val=right-min;
}
}
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
int right=0;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=(A[left]<A[i+1])?A[left]:A[i+1];
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=(A[left]<A[i+1])?A[left]:A[i+1];
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
if()
int right=(A[left]<A[i+1])?A[left]:A[i+1];
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
if(A[left]<A[i+1]){
}
int right=()?A[left]:A[i+1];
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right;
if(A[left]<A[i+1]){
right=A[left];
left=i+1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<A[i+1]){
right=A[left];
left=i+1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
i=left;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("")
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("A[%d]%d::",i,A[i],)
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("A[%d]%d::leftA[%d]%d .. ",i,A[i],)
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d]",i,A[i],)
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ",i,A[i],)
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..",i,A[i],)
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(min!=-1){
int val=A[left]-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..",i,A[i],)
if(ret<val) ret=val;
}
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..",i,A[i],)
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..right[%d]",i,A[i],left,A[left],min,right);
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..right[%d] = ret %d\n",i,A[i],left,A[left],min,right,ret);
if(ret<val) ret=val;
}
}
return ret;
}
A[3]1::leftA[1]3 .. min[1] ..right[2] = ret 0 A[5]1::leftA[6]5 .. min[-1] ..right[3] = ret 1 A[8]3::leftA[6]5 .. min[3] ..right[4] = ret 4
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
t
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..right[%d] = ret %d\n",i,A[i],left,A[left],min,right,ret);
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..right[%d] = ret %d\n",i,A[i],left,A[left],min,right,ret);
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
int left=0;
int min=-1;
for(int i=1;i<N-2;i++){
if(A[left]<A[i]){
if(A[i]>A[i+1]){
left=i;
}
}
if((min==-1)||(min>A[i])) min=A[i];
if(A[i]<A[i+1]){
int right=A[i+1];
if(A[left]<right){
right=A[left];
left=i+1;
min=-1;
}
int val=right-min;
printf("A[%d]%d::leftA[%d]%d .. min[%d] ..right[%d] = ret %d\n",i,A[i],left,A[left],min,right,ret);
if(ret<val) ret=val;
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
if(A[i]>A[i+1]){
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
if(A[i]>A[i+1]){
if(left.idx!=-1){
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("")
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("")
}
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
}
return ret;
}
func.c:3:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token typedef stflood{ ^ func.c:6:2: warning: data definition has no type or storage class }flood; ^~~~~ func.c:6:2: warning: type defaults to 'int' in declaration of 'flood' [-Wimplicit-int] func.c: In function 'solution': func.c:12:5: warning: statement with no effect [-Wunused-value] flood left; ^~~~~ func.c:12:11: error: expected ';' before 'left' flood left; ^~~~ func.c:13:5: warning: statement with no effect [-Wunused-value] flood right; ^~~~~ func.c:13:11: error: expected ';' before 'right' flood right; ^~~~~ func.c:14:5: warning: statement with no effect [-Wunused-value] flood min; ^~~~~ func.c:14:11: error: expected ';' before 'min' flood min; ^~~ func.c:15:5: error: 'left' undeclared (first use in this function) left.idx=-1; ^~~~ func.c:15:5: note: each undeclared identifier is reported only once for each function it appears in func.c:16:5: error: 'right' undeclared (first use in this function) right.idx=-1; ^~~~~ func.c:17:5: error: 'min' undeclared (first use in this function) min.idx=-1; ^~~
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef strustflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) A[2](2)::A[2+1](1) A[3](1)::A[3+1](2) A[4](2)::A[4+1](1) A[5](1)::A[5+1](5) A[6](5)::A[6+1](3) left[6](5) A[7](3)::A[7+1](3) A[8](3)::A[8+1](4) A[9](4)::A[9+1](2)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) left[1](3) A[2](2)::A[2+1](1) A[3](1)::A[3+1](2) A[4](2)::A[4+1](1) A[5](1)::A[5+1](5) A[6](5)::A[6+1](3) left[6](5) A[7](3)::A[7+1](3) A[8](3)::A[8+1](4) A[9](4)::A[9+1](2)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
else{
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
else{
if(min.idx==-1){
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
if(min.idx==-1){
min.idx=i
}
{
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
printf("left[%d](%d)\n",left.idx,left.val);
}
}
}
if(min.idx==-1){
min.idx=i;
min.val=A[i];
}
{
}
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
min.idx=i;
min.val=A[i];
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
min.idx=i;
min.val=A[i];
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
A[0](1)::A[0+1](3) left[-1](4196832) .. min[0](1) A[1](3)::A[1+1](2) left[1](3) .. min[0](1) A[2](2)::A[2+1](1) left[1](3) .. min[0](1) A[3](1)::A[3+1](2) left[1](3) .. min[0](1) A[4](2)::A[4+1](1) left[1](3) .. min[0](1) A[5](1)::A[5+1](5) left[1](3) .. min[0](1) A[6](5)::A[6+1](3) left[6](5) .. min[0](1) A[7](3)::A[7+1](3) left[6](5) .. min[0](1) A[8](3)::A[8+1](4) left[6](5) .. min[0](1) A[9](4)::A[9+1](2) left[6](5) .. min[0](1)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
min.idx=i;
min.val=A[i];
}
else
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
min.idx=i;
min.val=A[i];
}
else{
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
if(min.val>A[i])
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=-1;
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
A[0](1)::A[0+1](3) left[-1](-1224252653) .. min[-1](4196832) A[1](3)::A[1+1](2) left[1](3) .. min[1](3) A[2](2)::A[2+1](1) left[1](3) .. min[2](2) A[3](1)::A[3+1](2) left[1](3) .. min[3](1) A[4](2)::A[4+1](1) left[1](3) .. min[3](1) A[5](1)::A[5+1](5) left[1](3) .. min[3](1) A[6](5)::A[6+1](3) left[6](5) .. min[7](3) A[7](3)::A[7+1](3) left[6](5) .. min[7](3) A[8](3)::A[8+1](4) left[6](5) .. min[7](3) A[9](4)::A[9+1](2) left[6](5) .. min[7](3)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.idx==-1){
if(left.idx!=-1){
min.idx=i;
min.val=A[i];
}
}
else{
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
A[0](1)::A[0+1](3) left[-1](-1830247661) .. min[-1](-767406408) A[1](3)::A[1+1](2) left[1](3) .. min[2](2) A[2](2)::A[2+1](1) left[1](3) .. min[2](2) A[3](1)::A[3+1](2) left[1](3) .. min[3](1) A[4](2)::A[4+1](1) left[1](3) .. min[3](1) A[5](1)::A[5+1](5) left[1](3) .. min[3](1) A[6](5)::A[6+1](3) left[6](5) .. min[7](3) A[7](3)::A[7+1](3) left[6](5) .. min[7](3) A[8](3)::A[8+1](4) left[6](5) .. min[7](3) A[9](4)::A[9+1](2) left[6](5) .. min[7](3)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if(left.idx==-1)printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) left[1](3) .. min[2](2) A[2](2)::A[2+1](1) left[1](3) .. min[2](2) A[3](1)::A[3+1](2) left[1](3) .. min[3](1) A[4](2)::A[4+1](1) left[1](3) .. min[3](1) A[5](1)::A[5+1](5) left[1](3) .. min[3](1) A[6](5)::A[6+1](3) left[6](5) .. min[7](3) A[7](3)::A[7+1](3) left[6](5) .. min[7](3) A[8](3)::A[8+1](4) left[6](5) .. min[7](3) A[9](4)::A[9+1](2) left[6](5) .. min[7](3)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if(A[i]<A[i+1])
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if(A[i]<A[i+1]){
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
left.
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
left.idx=i+1;
left.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
int val=left.val-min;
left.idx=i+1;
left.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i+1;
min.val=A[i+1];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
else{
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
int val=left.val-min;
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
int val=A[i+1]-min;
if(left.val<A[i+1]){
int val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
int val=A[i+1]-min;
if(left.val<A[i+1]){
val=left.val-min;
if(ret<val) ret=val;
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
int val=A[i+1]-min;
if(left.val<A[i+1]){
val=left.val-min;
}
if(left.val<A[i+1]){
left.idx=i+1;
left.val=A[i+1];
min.idx=i+1;
min.val=A[i+1];
}
if(ret<val) ret=val;
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(left.idx!=-1) printf("left[%d](%d) .. min[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,min.idx,min.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) L[1](3) .. M[1](3) .. R[-1](11159) A[2](2)::A[2+1](1) L[1](3) .. M[2](2) .. R[-1](11159) A[3](1)::A[3+1](2) L[1](3) .. M[3](1) .. R[4](2) A[4](2)::A[4+1](1) L[1](3) .. M[3](1) .. R[4](2) A[5](1)::A[5+1](5) L[1](3) .. M[3](1) .. R[6](5) A[6](5)::A[6+1](3) L[6](5) .. M[6](5) .. R[6](5) A[7](3)::A[7+1](3) L[6](5) .. M[7](3) .. R[6](5) A[8](3)::A[8+1](4) L[6](5) .. M[7](3) .. R[9](4) A[9](4)::A[9+1](2) L[6](5) .. M[7](3) .. R[9](4)
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>left.idx)
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>left.idx){
if(min.idx>)
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>left.idx){
if(min.idx>left.idx){
if()
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>left.idx){
if(min.idx>left.idx){
if(right.idx>)
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>left.idx){
if(min.idx>left.idx){
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=((left.val>right.val)?right.val:left.val)-min;
if(ret<val) ret=val;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d)\n",left.idx,left.val,min.idx,min.val,right.idx,right.val);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=((left.val>right.val)?right.val:left.val)-min;
if(ret<val) ret=val;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
func.c: In function 'solution': func.c:46:66: error: invalid operands to binary - (have 'int' and 'flood {aka struct stflood}') int val=((left.val>right.val)?right.val:left.val)-min; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=((left.val>right.val)?right.val:left.val);
if(ret<val) ret=val;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=((left.val>right.val)?right.val:left.val);
int depth=val-min;
if(ret<val) ret=val;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=((left.val>right.val)?right.val:left.val);
int depth=val-min;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
func.c: In function 'solution': func.c:47:30: error: invalid operands to binary - (have 'int' and 'flood {aka struct stflood}') int depth=val-min; ^
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
int depth=val-min;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
int depth=val-min;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
func.c: In function 'solution': func.c:47:30: error: invalid operands to binary - (have 'int' and 'flood {aka struct stflood}') int depth=val-min; ^
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
int depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) L[1](3) .. M[1](3) .. R[-1](32764) = 0 A[2](2)::A[2+1](1) L[1](3) .. M[2](2) .. R[-1](32764) = 0 A[3](1)::A[3+1](2) L[1](3) .. M[3](1) .. R[4](2) = 1 A[4](2)::A[4+1](1) L[1](3) .. M[3](1) .. R[4](2) = 1 A[5](1)::A[5+1](5) L[1](3) .. M[3](1) .. R[6](5) = 2 A[6](5)::A[6+1](3) L[6](5) .. M[6](5) .. R[6](5) = 2 A[7](3)::A[7+1](3) L[6](5) .. M[7](3) .. R[6](5) = 2 A[8](3)::A[8+1](4) L[6](5) .. M[7](3) .. R[9](4) = 2 A[9](4)::A[9+1](2) L[6](5) .. M[7](3) .. R[9](4) = 2
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) = %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) L[1](3) .. M[1](3) .. R[-1](32766) = 0 A[2](2)::A[2+1](1) L[1](3) .. M[2](2) .. R[-1](32766) = 0 A[3](1)::A[3+1](2) L[1](3) .. M[3](1) .. R[4](2) = 1 A[4](2)::A[4+1](1) L[1](3) .. M[3](1) .. R[4](2) = 1 A[5](1)::A[5+1](5) L[1](3) .. M[3](1) .. R[6](5) = 2 A[6](5)::A[6+1](3) L[6](5) .. M[6](5) .. R[6](5) = 2 A[7](3)::A[7+1](3) L[6](5) .. M[7](3) .. R[6](5) = 2 A[8](3)::A[8+1](4) L[6](5) .. M[7](3) .. R[9](4) = 2 A[9](4)::A[9+1](2) L[6](5) .. M[7](3) .. R[9](4) = 2
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,ret);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(%d) ret= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,depth,ret);
}
return ret;
}
A[0](1)::A[0+1](3) A[1](3)::A[1+1](2) L[1](3) .. M[1](3) .. R[-1](1189962576) D(0) ret= 0 A[2](2)::A[2+1](1) L[1](3) .. M[2](2) .. R[-1](1189962576) D(0) ret= 0 A[3](1)::A[3+1](2) L[1](3) .. M[3](1) .. R[4](2) D(1) ret= 1 A[4](2)::A[4+1](1) L[1](3) .. M[3](1) .. R[4](2) D(1) ret= 1 A[5](1)::A[5+1](5) L[1](3) .. M[3](1) .. R[6](5) D(2) ret= 2 A[6](5)::A[6+1](3) L[6](5) .. M[6](5) .. R[6](5) D(2) ret= 2 A[7](3)::A[7+1](3) L[6](5) .. M[7](3) .. R[6](5) D(2) ret= 2 A[8](3)::A[8+1](4) L[6](5) .. M[7](3) .. R[9](4) D(1) ret= 2 A[9](4)::A[9+1](2) L[6](5) .. M[7](3) .. R[9](4) D(1) ret= 2
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
//printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(%d) ret= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,depth,ret);
}
return ret;
}
L[1](3) .. M[1](3) .. R[-1](582) D(0) ret= 0 L[1](3) .. M[2](2) .. R[-1](582) D(0) ret= 0 L[1](3) .. M[3](1) .. R[4](2) D(1) ret= 1 L[1](3) .. M[3](1) .. R[4](2) D(1) ret= 1 L[1](3) .. M[3](1) .. R[6](5) D(2) ret= 2 L[6](5) .. M[6](5) .. R[6](5) D(2) ret= 2 L[6](5) .. M[7](3) .. R[6](5) D(2) ret= 2 L[6](5) .. M[7](3) .. R[9](4) D(1) ret= 2 L[6](5) .. M[7](3) .. R[9](4) D(1) ret= 2
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
//printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(%d) ret= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,depth,ret);
}
return ret;
}
[3, 1, 2]
L[1](3) .. M[1](3) .. R[-1](582) D(0) ret= 0 L[1](3) .. M[2](2) .. R[-1](582) D(0) ret= 0 L[1](3) .. M[3](1) .. R[4](2) D(1) ret= 1 L[1](3) .. M[3](1) .. R[4](2) D(1) ret= 1 L[1](3) .. M[3](1) .. R[6](5) D(2) ret= 2 L[6](5) .. M[6](5) .. R[6](5) D(2) ret= 2 L[6](5) .. M[7](3) .. R[6](5) D(2) ret= 2 L[6](5) .. M[7](3) .. R[9](4) D(1) ret= 2 L[6](5) .. M[7](3) .. R[9](4) D(1) ret= 2
function result: 1
L[0](3) .. M[0](3) .. R[-1](582) D(0) ret= 0 L[0](3) .. M[1](1) .. R[2](2) D(1) ret= 1
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
//printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
//if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(%d) ret= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,depth,ret);
}
return ret;
}
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
//printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
//if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(%d) ret= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,depth,ret);
}
return ret;
}
[3, 1, 2]
// you can write to stdout for debugging purposes, e.g.
// printf("this is a debug message\n");
typedef struct stflood{
int idx;
int val;
}flood;
int solution(int A[], int N) {
// write your code in C99 (gcc 6.2.0)
int ret=0;
int depth=0;
if(N<3) return ret;
flood left;
flood right;
flood min;
left.idx=-1;
right.idx=-1;
min.idx=-1;
for(int i=0;i<N-1;i++){
//printf("A[%d](%d)::A[%d+1](%d)\n",i,A[i],i,A[i+1]);
if(A[i]>A[i+1]){
if(left.idx==-1){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
else{
if(left.val<A[i]){
left.idx=i;
left.val=A[i];
min.idx=i;
min.val=A[i];
}
}
}
if(min.val>A[i]){
min.idx=i;
min.val=A[i];
}
if((left.idx!=-1)&&(A[i]<A[i+1])){
right.idx=i+1;
right.val=A[i+1];
}
if(right.idx>min.idx){
if(min.idx>left.idx){
int val=(left.val>right.val)?right.val:left.val;
depth=val-min.val;
if(ret<depth) ret=depth;
}
}
//if(left.idx!=-1) printf("L[%d](%d) .. M[%d](%d) .. R[%d](%d) D(%d) ret= %d\n",left.idx,left.val,min.idx,min.val,right.idx,right.val,depth,ret);
}
return ret;
}
The solution obtained perfect score.
randomized values which grow when distance from the center decreases, N ~= 100,000