Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream f("date.in");
  6. ofstream g("date.out");
  7.  
  8. int n,v[101],st,curent,a,b,dr,lmax;
  9.  
  10. int main()
  11. {
  12.     f>>n;
  13.     for(int i=1;i<=n;i++) f>>v[i];
  14.     st=1; curent=v[1];
  15.     for(int i=2;i<=n+1;i++)
  16.     {
  17.         if(curent<=v[i])
  18.         {
  19.             dr=i;
  20.             curent=v[i];
  21.         }
  22.         else
  23.         {
  24.             if(dr-st+1>lmax)
  25.             {
  26.                 lmax=dr-st+1;
  27.                 a=st;
  28.                 b=dr;
  29.             }
  30.             st=i;
  31.             curent=v[st];
  32.         }
  33.     }
  34.     for(int i=a;i<=b;i++) cout<<v[i]<<" ";
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement