제출 #727175

#제출 시각아이디문제언어결과실행 시간메모리
727175NeroZeinFinancial Report (JOI21_financial)C++17
28 / 100
217 ms260444 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 405; int a[N]; int n, d; int dp[N][N][N]; int bt (int id, int mx, int la) { if (id == n) return 0; int& ret = dp[id][mx][la]; if (ret != -1) { return ret; } if (id - la > d && mx != 0) return 0; ret = max(bt(id + 1, mx, la), bt(id + 1, max(mx, a[id]), id) + (int) (a[id] > mx)); 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; } memset(dp, -1, sizeof dp); cout << bt(0, 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...