Submission #721851

#TimeUsernameProblemLanguageResultExecution timeMemory
721851kas_sUplifting Excursion (BOI22_vault)C++17
0 / 100
5057 ms524288 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; int main () { ios::sync_with_stdio(0); cin.tie(0); int M; long long L; cin >> M >> L; map<long long, int> sums; sums[0] = 0; vector<int> a; for (int i = -M, x; i <= M; i++) { cin >> x; for (int j = 0; j < x; j++) { a.push_back(i); } } int N = (int)a.size(); for (int i = 0; i < N; i++) { map<int, int> curr; for (auto &[k, v]: sums) { curr[a[i] + k] = max(curr[a[i] + k], v + 1); } for (auto &[k, v]: curr) { sums[k] = max(sums[k], v); } } if (sums.count(L)) { cout << sums[L] << '\n'; } else { cout << "impossible\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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...