Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h> //inf=0x3f3f3f3f;//printf("%.10lf\n",x);
- #define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- using namespace std;
- typedef long long ll;
- const int N=1e5+20;
- int n,a[N],dp[N],ans;
- void coast(int prev){
- if(prev==n-1){
- if(a[prev]>=a[prev-1])dp[prev]=dp[prev-1]+1;
- else dp[prev]=1;
- ans=max(ans,dp[prev]);
- }dp[prev]=1;
- for(int i=prev+1;i<n;i++){
- if(a[i-1]<=a[i]){dp[i]=1+dp[i-1];ans=max(ans,dp[i]);}
- else coast(i);
- }
- }
- int main()
- {
- ROCK;
- cin>>n;for(int i=0;i<n;i++)cin>>a[i];
- coast(0);cout<<ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement