Submission #702117

#TimeUsernameProblemLanguageResultExecution timeMemory
702117ld_minh4354Financial Report (JOI21_financial)C++14
48 / 100
2102 ms107664 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define debug(x) cout<<#x<<": "<<x<<"\n" signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("input.000","r",stdin); // freopen("output.000","w",stdout); // srand((unsigned)time(NULL)); // rand() int n,a[300005],dp[300005],i,max_dist,c,d,j,ans; bool reach[7005][7005]; cin>>n>>d; for (i=1;i<n+1;i++) cin>>a[i]; for (i=1;i<n;i++) { max_dist=0;c=0; reach[i][i+1]=(a[i]<a[i+1]); for (j=i+1;j<n;j++) { if (a[i]<a[j]) { c++;max_dist=max(max_dist,c); } else c=0; reach[i][j+1]=(max_dist<d and a[i]<a[j+1]); } } dp[1]=1; for (i=2;i<n+1;i++) { dp[i]=1; for (j=1;j<i;j++) if (reach[j][i]) dp[i]=max(dp[i],dp[j]+1); } ans=1; for (i=2;i<n+1;i++) ans=max(ans,dp[i]); cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...