Submission #546060

#TimeUsernameProblemLanguageResultExecution timeMemory
546060AJ00Financial Report (JOI21_financial)C++14
0 / 100
4030 ms10152 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dp[300000],minm[300000],a[300000]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t=1,n,d; // cin >> t; while (t--){ cin >> n >> d; for (int i = 0; i < n; i++){ cin >> a[i]; } int ans = 1; dp[n-1] = 1; minm[n-1] = a[n-1]; for (int i = n-2; i >= 0; i--){ dp[i] = 1; minm[i] = a[i]; int j = i+1,cur=0; while(j < n && cur < d){ if (a[i] < minm[j] && dp[i] < dp[j]+1){ dp[i] = dp[j]+1; minm[i] = a[i]; // cout << "a " << dp[i] << " " << maxm[i] << "\n"; } /* else if (dp[i] < dp[j]){ dp[i] = dp[j]; minm[i] = minm[j]; // cout << "b " << dp[i] << " " << maxm[i] << "\n"; }*/ j++; cur++; } ans = max(ans,dp[i]); //cout << i+1 << " " << dp[i] << "\n\n"; } cout << ans << "\n"; //cout << dp[n-1] << "\n"; } return 0; }
#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...