제출 #419845

#제출 시각아이디문제언어결과실행 시간메모리
419845schseFinancial Report (JOI21_financial)C++17
0 / 100
569 ms511368 KiB
#include <bits/stdc++.h> using namespace std; int N, D; vector<int> arr; vector<vector<int>> dp = vector<vector<int>>(8000, vector<int>(8000, -1)); int rec(int n, int cmax = -1) { int score = arr[n] > cmax ? 1 : 0; int tmp = 0; int cmal = cmax; if (dp[n][cmax] != -1) return dp[n][cmax]; if (n == N - 1) return dp[n][cmax] = score; cmax = max(cmax, arr[n]); for (int i = 1; i <= D && i + n <= N - 1; i++) tmp = max(tmp, rec(n + i, cmax)); return dp[n][cmal] = score + tmp; } int main() { cin >> N >> D; arr.resize(N); for (int &i : arr) cin >> i; assert(N <= 400); //compression { vector<int> arr2 = arr; sort(arr2.begin(), arr2.end()); map<int, int> copr; int c = 1; copr[arr2[0]] = ++c; for (int i = 1; i < N; i++) if (arr2[i - 1] < arr2[i]) copr[arr2[i]] = ++c; for (int &i : arr) i = copr[i]; } int score = 0; for (int i = 0; i < N; i++) score = max(score, rec(i)); cout << score; }
#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...