# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
588637 | 2022-07-03T18:27:45 Z | peuch | Uplifting Excursion (BOI22_vault) | C++17 | 0 ms | 212 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 610; const long long INF = 1e18; int m; long long l; long long aux[MAXN]; long long *v = aux + 300; int main(){ scanf("%d %lld", &m, &l); for(int i = -m; i <= m; i++) scanf("%lld", &v[i]); long long sum = 0; long long cnt = 0; for(int i = 1; i <= m; i++){ if(sum + v[i] * i <= l){ sum += v[i] * i; cnt += v[i]; continue; } cnt += ((l - sum) / i + 1); sum += i * ((l - sum) / i + 1); } if(sum < l){ printf("impossible\n"); return 0; } vector<long long> dp(sum - l + 1, INF); dp[0] = 0; vector<int> moedas; for(int i = 1; i <= m; i++){ for(int j = 0; j < min(300LL, v[i]); j++) moedas.push_back(i); } for(int i = 0; i < moedas.size(); i++){ for(int j = moedas[i]; j < dp.size(); j++){ dp[j] = min(dp[j], dp[j - moedas[i]] + 1); } } if(dp.back() == INF) printf("impossible\n"); else printf("%lld\n", v[0] + cnt - dp.back()); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |