This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main () {
ios::sync_with_stdio(0); cin.tie(0);
int M, L;
cin >> M >> L;
map<int, 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |