We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
i did'nt use stack.but any how all testcases passed.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */longlongn,arr[100001],i,j,max,temp=-1,k,count=1,val;cin>>n;for(i=0;i<n;i++){cin>>arr[i];}for(i=0;i<n;i++){val=arr[i];intcl1=1,cl=1;for(j=i-1,k=i+1;j>=0||k<n;j--,k++){if(j>=0&&arr[j]>=val&&cl1==1){count++;}elsecl1=0;if(k<n&&arr[k]>=val&&cl==1){count++;}elsecl=0;if(cl==0&&cl1==0)break;}max=val*count;if(max>temp){temp=max;}count=1;}cout<<temp;return0;}
Largest Rectangle
You are viewing a single comment's thread. Return to all comments →
i did'nt use stack.but any how all testcases passed.