We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2e1d7d commit bb1a649Copy full SHA for bb1a649
histogram-h.cpp
@@ -0,0 +1,27 @@
1
+#include<iostream>
2
+using namespace std;
3
+
4
+int main(){
5
+ long long int ans=0;
6
+ int i,n,arr[10010];
7
+ cin>>n;
8
+ for(i=0;i<n;i++)
9
+ cin>>arr[i];
10
+ int beg=0,en=n-1;
11
+ while(beg<=en){
12
+ if(arr[beg]<=arr[en]){
13
+ long long int current =(en-beg) * arr[beg];
14
+ if(current > ans)
15
+ ans=current;
16
+ beg++;
17
+ }
18
+ else{
19
+ long long int current =(en-beg) * arr[en];
20
21
22
+ en--;
23
24
25
+ cout<<ans;
26
+ return 0;
27
+}
0 commit comments