Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3. #include <utility>
  4. #include <algorithm>
  5. using namespace std;
  6. stack<pair<int, int> >hello;
  7. int main() {
  8. int a,b,i,m=0,last,count=0;
  9. cin>>a>>b;
  10. hello.push(make_pair(b,0));
  11. while(cin>>b) {
  12. count++;
  13. last=count;
  14. while((hello.top().first)>b) {
  15. m=max((hello.top().first)*(count-hello.top().second),m);
  16. last=hello.top().second;
  17. hello.pop();
  18. if(hello.empty()) hello.push(make_pair(b,last));
  19. }
  20. if((hello.top().first)<b) hello.push(make_pair(b,last));
  21. }
  22. while(!hello.empty()) {
  23. m=max((hello.top().first)*(count-hello.top().second+1),m);
  24. hello.pop();
  25. }
  26. cout<<m;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement