Submission #528543

#TimeUsernameProblemLanguageResultExecution timeMemory
528543ShinFinancial Report (JOI21_financial)C++14
48 / 100
78 ms4444 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define TASK "task" #define all(x) x.begin(), x.end() using namespace std; const int N = 2e5 + 7; const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const long long INFLL = 1e18 + 7; template <class X, class Y> bool minimize(X &a, Y b) { if (a > b) return a = b, true; return false; } template <class X, class Y> bool maximize(X &a, Y b) { if (a < b) return a = b, true; return false; } int n, D; int a[N]; int dp[N]; void solve(void) { cin >> n >> D; for (int i = 1; i <= n; i ++) cin >> a[i]; int res = 1; for (int i = n; i > 0; i --) { dp[i] = 1; for (int j = i + 1, lim = i + D; j <= min(lim, n); j ++) { if (a[i] >= a[j]) { lim = j + D; } else { maximize(dp[i], dp[j] + 1); } } maximize(res, dp[i]); } cout << res; } signed main(void) { cin.tie(0)->sync_with_stdio(0); int test = 1; // cin >> test; while (test --) { solve(); } 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...