-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhack.cpp
More file actions
52 lines (51 loc) · 701 Bytes
/
hack.cpp
File metadata and controls
52 lines (51 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
using namespace std;
int a[100000];
int maxarray[100000];
void findmax(int n)
{
int i=1;
int large=maxarray[0];
while(i<n)
{
if(large<maxarray[i])
large=maxarray[i];
i++;
}
cout<<"The largest area of rectangle:"<<large<<endl;
}
void largesum(int n)
{
int i=0;
for(;i<n;i++)
{
int count=0;
int j=i-1;
int k=i+1;
while(j>=0 && a[j]>=a[i])
{
count++;
j--;
}
while(k<n && a[k]>=a[i])
{
count++;
k++;
}
count++;
maxarray[i]=count*a[i];
}
findmax(n);
}
int main()
{
int n=0;
cout<<"Enter the no.of elements:"<<endl;
cin>>n;
cout<<"Enter the elements:"<<endl;
int i=0;
for(;i<n;i++)
cin>>a[i];
largesum(n);
return 0;
}