You are on page 1of 1

/******************************************************************************

Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

int matrix[100][100],array[100],i,j;
int min(int a,int b,int i,int j){
return ((matrix[i][j-1]>array[j])?array[j]:matrix[i][j-1]);
}

int main()
{
int n,i,j;
scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&array[i]);
}

int start,end;
scanf("%d",&start);
scanf("%d",&end);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(i==j ||j>i){
if(i==j){
matrix[i][j]=array[j];
}
else{
matrix[i][j]=min(matrix[i][j-1],array[j],i,j);
}
}
else matrix[i][j]=0;

}
}
printf("%d",matrix[start][end]);

return 0;
}

You might also like