제출 #654156

#제출 시각아이디문제언어결과실행 시간메모리
654156FarbodFinancial Report (JOI21_financial)C++17
48 / 100
272 ms44220 KiB
#include <iostream> #include <vector> using namespace std; const int N = 7005; int n, d, a[N], dp[N], ans = 1; 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), 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...