Submission #581467

#TimeUsernameProblemLanguageResultExecution timeMemory
581467colossal_pepeFinancial Report (JOI21_financial)C++17
0 / 100
2236 ms146744 KiB
#include <iostream> #include <cstring> using namespace std; const int N = 405; int n, d, a[N], dp[N][N][N]; bool vis[N][N][N]; int brutus(int i, int j, int k) { if (i > n) return (j == n ? 0 : -1000); if (vis[i][j][k]) return dp[i][j][k]; vis[i][j][k] = 1; if (j != 0 and i - j > d) dp[i][j][k] = -1000; else dp[i][j][k] = max(brutus(i + 1, j, k), (a[i] > a[k]) + brutus(i + 1, i, (a[i] > a[k] ? i : k))); return dp[i][j][k]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> d; a[0] = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; } // if (n > 400) cout << "parbona" << '\n'; memset(vis, 0, sizeof(vis)); cout << brutus(1, 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...