# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829159 | 2023-08-18T05:39:38 Z | 1075508020060209tc | Kitchen (BOI19_kitchen) | C++14 | 91 ms | 92208 KB |
#pragma GCC optimize("Ofast, no-stack-protector, unroll-loops") #include <bits/stdc++.h> using namespace std; //#define int long long int n;int m;int K; int ar[510]; int br[510]; int dp[310][90010]; signed main() { cin>>n>>m>>K; for(int i=1;i<=n;i++){ cin>>ar[i]; } for(int i=1;i<=m;i++){ cin>>br[i]; } int S=0; for(int i=1;i<=n;i++){ if(ar[i]<K){cout<<"Impossible";return 0;} S+=ar[i]; } for(int i=0;i<m;i++){ for(int j=0;j<=90000;j++){ if(dp[i][j]==0&&i!=0){continue;} dp[i+1][j]=max(dp[i+1][j],dp[i][j]); int v=j+br[i+1]; if(v>90000){continue;} dp[i+1][v]=max(dp[i+1][v],dp[i][j]+min(n,br[i+1])); } } for(int i=S;i<=90000;i++){ if(dp[m][i]>=n*K){ cout<<i-S<<endl;return 0; } } cout<<"Impossible"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Incorrect | 1 ms | 948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Incorrect | 1 ms | 948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 91 ms | 92208 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 14292 KB | Output is correct |
2 | Correct | 14 ms | 14364 KB | Output is correct |
3 | Correct | 14 ms | 14388 KB | Output is correct |
4 | Correct | 14 ms | 14344 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Incorrect | 1 ms | 948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |