Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- #include <utility>
- #include <algorithm>
- using namespace std;
- stack<pair<int, int> >hello;
- int main() {
- int a,b,i,m=0,last,count=0;
- cin>>a>>b;
- hello.push(make_pair(b,0));
- while(cin>>b) {
- count++;
- last=count;
- while((hello.top().first)>b) {
- m=max((hello.top().first)*(count-hello.top().second),m);
- last=hello.top().second;
- hello.pop();
- if(hello.empty()) hello.push(make_pair(b,last));
- }
- if((hello.top().first)<b) hello.push(make_pair(b,last));
- }
- while(!hello.empty()) {
- m=max((hello.top().first)*(count-hello.top().second+1),m);
- hello.pop();
- }
- cout<<m;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement