# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580452 | 2022-06-21T09:14:50 Z | 조영욱(#8357) | Uplifting Excursion (BOI22_vault) | C++17 | 1921 ms | 16172 KB |
#include <bits/stdc++.h> using namespace std; int m; long long l; int dp0[1000001]; int dp[1000001]; const int zero=500000; long long arr[202]; typedef pair<int,int> P; int main(void) { scanf("%d %lld",&m,&l); for(int i=1;i<=m*2+1;i++) { scanf("%lld",&arr[i]); } long long total=l; for(int i=m+2;i<=m*2+1;i++) { long long use=total/(i-m-1); use=min(use,arr[i]); total-=1LL*use*(i-m-1); use=max(use-100,0LL); arr[i]-=use; l-=1LL*use*(i-m-1); if (arr[i]>100) { arr[i]=100; } } for(int i=0;i<=zero*2;i++) { dp0[i]=-1e7; dp[i]=-1e7; } dp[zero]=0; for(int i=1;i<=m*2+1;i++) { if (i==m+1){ for(int j=0;j<=zero*2;j++) { dp[j]=dp[j]+arr[m+1]; } continue; } int val=abs(i-m-1); if (i<m+1) { for(int j=zero*2;j>zero*2-val;j--) { deque<P> dq; for(int k=j;k>=0;k-=val) { int now=dp[k]+k/val; while (!dq.empty()&&dq.back().second>k+arr[i]*val) { dq.pop_back(); } while (!dq.empty()&&dq.front().first<=now) { dq.pop_front(); } dq.push_front(P(now,k)); dp0[k]=max(dp0[k],dq.back().first-k/val); } } } else { for(int j=0;j<val;j++) { deque<P> dq; for(int k=j;k<=zero*2;k+=val) { int now=dp[k]-k/val; while (!dq.empty()&&dq.back().second<k-arr[i]*val) { dq.pop_back(); } while (!dq.empty()&&dq.front().first<=now) { dq.pop_front(); } dq.push_front(P(now,k)); dp0[k]=max(dp0[k],dq.back().first+k/val); } } } for(int j=0;j<=zero*2;j++) { dp[j]=dp0[j]; dp0[j]=-1e7; } } if (dp[zero+l]<0) { printf("impossible"); return 0; } printf("%d",dp[zero+l]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 8108 KB | Output is correct |
2 | Correct | 88 ms | 8104 KB | Output is correct |
3 | Correct | 33 ms | 8020 KB | Output is correct |
4 | Correct | 330 ms | 8112 KB | Output is correct |
5 | Runtime error | 1921 ms | 16172 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 8108 KB | Output is correct |
2 | Correct | 88 ms | 8104 KB | Output is correct |
3 | Correct | 33 ms | 8020 KB | Output is correct |
4 | Correct | 330 ms | 8112 KB | Output is correct |
5 | Runtime error | 1921 ms | 16172 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 305 ms | 8108 KB | Output is correct |
2 | Incorrect | 932 ms | 8108 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 305 ms | 8108 KB | Output is correct |
2 | Incorrect | 932 ms | 8108 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 305 ms | 8108 KB | Output is correct |
2 | Incorrect | 932 ms | 8108 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 8108 KB | Output is correct |
2 | Correct | 88 ms | 8104 KB | Output is correct |
3 | Correct | 33 ms | 8020 KB | Output is correct |
4 | Correct | 330 ms | 8112 KB | Output is correct |
5 | Runtime error | 1921 ms | 16172 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 305 ms | 8108 KB | Output is correct |
2 | Incorrect | 932 ms | 8108 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 8108 KB | Output is correct |
2 | Correct | 88 ms | 8104 KB | Output is correct |
3 | Correct | 33 ms | 8020 KB | Output is correct |
4 | Correct | 330 ms | 8112 KB | Output is correct |
5 | Runtime error | 1921 ms | 16172 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 305 ms | 8108 KB | Output is correct |
2 | Incorrect | 932 ms | 8108 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 8108 KB | Output is correct |
2 | Correct | 88 ms | 8104 KB | Output is correct |
3 | Correct | 33 ms | 8020 KB | Output is correct |
4 | Correct | 330 ms | 8112 KB | Output is correct |
5 | Runtime error | 1921 ms | 16172 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |