Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h> //inf=0x3f3f3f3f;//printf("%.10lf\n",x);
  2. #define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  3. using namespace std;
  4. typedef long long ll;
  5. const int N=1e5+20;
  6. int n,a[N],dp[N],ans;
  7.  
  8. void coast(int prev){
  9. if(prev==n-1){
  10. if(a[prev]>=a[prev-1])dp[prev]=dp[prev-1]+1;
  11. else dp[prev]=1;
  12. ans=max(ans,dp[prev]);
  13. }dp[prev]=1;
  14. for(int i=prev+1;i<n;i++){
  15. if(a[i-1]<=a[i]){dp[i]=1+dp[i-1];ans=max(ans,dp[i]);}
  16. else coast(i);
  17. }
  18. }
  19.  
  20.  
  21. int main()
  22. {
  23. ROCK;
  24. cin>>n;for(int i=0;i<n;i++)cin>>a[i];
  25. coast(0);cout<<ans;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement