Submission #673214

#TimeUsernameProblemLanguageResultExecution timeMemory
673214Hacv16Jelly Flavours (IOI20_jelly)C++17
0 / 100
2082 ms94416 KiB
#include "jelly.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 10; const int MAXM = 1e4 + 10; const int INF = 0x3f3f3f3f; int dp[MAXN][MAXM]; int dp2[MAXN][MAXM]; int n, a[MAXN], b[MAXN]; int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b) { n = _a.size(); if(x > y){ swap(x, y); swap(_a, _b); } for(int i = 1; i <= n; i++) { a[i] = _a[i - 1]; b[i] = _b[i - 1]; } for(int i = 1; i <= n; i++){ for(int j = 0; j <= x; j++){ dp[i][j] = dp[i - 1][j]; if(j >= a[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]] + 1); } } int i = n, j = x; while(i != 0){ if(dp[i][j] == dp[i - 1][j]) i--; else if(dp[i][j] == dp[i - 1][j - a[i]] + 1){ i--, j -= a[i], b[i] = INF; } } for(int i = 1; i <= n; i++){ for(int j = 0; j <= y; j++){ dp2[i][j] = dp2[i - 1][j]; if(j >= b[i]) dp2[i][j] = max(dp2[i][j], dp2[i - 1][j - b[i]] + 1); } } return (dp[n][x] + dp2[n][y]); }
#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...