Submission #654152

#TimeUsernameProblemLanguageResultExecution timeMemory
654152FarbodFinancial Report (JOI21_financial)C++17
0 / 100
5 ms468 KiB
#include <iostream> #include <vector> using namespace std; const int N = 7005; int n, d, a[N], dp[N], ans = 0; bool f[N][N]; signed main() { cin >> n >> d; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { vector <int> v; v.push_back(i); for (int j = i - 1; j >= 0; j--) { if (v.back() - j > d) break; if (a[j] <= a[i]) v.push_back(j); if (a[j] < a[i]) f[j][i] = 1; } } dp[n - 1] = 1; for (int i = n - 2; i >= 0; i--) { dp[i] = 1; for (int j = i + 1; j < n; j++) if (f[i][j]) dp[i] = max(dp[i], dp[j] + 1); ans = max(ans, dp[i]); } cout << ans; 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...