Submission #661035

#TimeUsernameProblemLanguageResultExecution timeMemory
661035GusterGoose27Uplifting Excursion (BOI22_vault)C++11
0 / 100
585 ms4452 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; const int MAXN = 100; const int MXVAL = 505000; int n; ll target; int cnt[2*MAXN+1]; int mx_use[MXVAL+1]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> target; if (target > MXVAL) { cout << "impossible\n"; return 0; } fill(mx_use, mx_use+MXVAL+1, -1); mx_use[0] = 0; for (int i = 0; i <= 2*n; i++) cin >> cnt[i]; for (int j = 1; j <= n; j++) { for (int i = MXVAL; i >= j; i--) { for (int p = 1; p <= cnt[n+j] && i-p*j >= 0; p++) if (mx_use[i-p*j] >= 0) mx_use[i] = max(mx_use[i], mx_use[i-p*j]+p); } } for (int j = 1; j <= n; j++) { for (int i = target; i <= MXVAL-j; i++) { for (int p = 1; p <= cnt[n-j] && i+p*j <= MXVAL; p++) if (mx_use[i+p*j] >= 0) mx_use[i] = max(mx_use[i], mx_use[i+p*j]+p); } } if (mx_use[target] == -1) { cout << "impossible\n"; return 0; } cout << (mx_use[target]+cnt[n]) << "\n"; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...