# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577788 | patrikpavic2 | Uplifting Excursion (BOI22_vault) | C++17 | 1364 ms | 332 KiB |
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 <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int M = 102;
const int GR = M * M;
const int INF = 0x3f3f3f3f;
int m;
ll L, A[M], kol;
int dp[GR + M];
int main(){
scanf("%d%lld", &m, &L);
for(int i = m;i >= 1;i--){
ll x; scanf("%lld", &x);
// A[i] += x; L += x * i;
}
ll bla; scanf("%lld", &bla);
for(int i = 1;i <= m;i++){
ll x; scanf("%lld", &x);
A[i] += x;
}
for(int i = 1;i <= m;i++){
ll uz = min(A[i], max(L - GR, 0LL) / i);
kol += uz; L -= uz * i;
A[i] -= uz;
A[i] = min((ll)GR, A[i]);
}
for(int i = 1;i < GR + M;i++)
dp[i] = -INF;
for(int i = 1;i <= m;i++){
for(int j = 0;j < A[i];j++){
for(int k = GR + M - 1;k >= i;k--)
dp[k] = max(dp[k], 1 + dp[k - i]);
}
}
if(L >= GR + M || dp[L] < 0)
printf("impossible\n");
else
printf("%lld\n", kol + dp[L] + bla);
return 0;
}
Compilation message (stderr)
# | 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... |