제출 #727171

#제출 시각아이디문제언어결과실행 시간메모리
727171NeroZeinFinancial Report (JOI21_financial)C++17
14 / 100
85 ms194624 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 7005; int a[N]; int la[N][N]; int n, d; int dp[N][N]; int bt (int id, int mx) { if (id == n) return 0; int& ret = dp[id][mx]; if (ret != -1) { return ret; } if (a[id] <= mx) { return ret = bt(id + 1, mx); } if (id - la[mx][id] > d) { return 0; } ret = max(bt(id + 1, mx), bt(id + 1, a[id]) + 1); return ret; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> d; vector<int> b(n); for (int i = 0; i < n; ++i) { cin >> a[i]; b[i] = a[i]; } sort(b.begin(), b.end()); b.resize(unique(b.begin(), b.end()) - b.begin()); for (int i = 0; i < n; ++i) { a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 1; } for (int i = 0; i < n; ++i) { la[0][i] = i; for (int j = 1; j <= n; ++j) { if (j >= a[i]) { la[j][i] = i; } else { la[j][i] = (i ? la[j][i - 1] : 0); } } } memset(dp, -1, sizeof dp); cout << bt(0, 0) << '\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...