# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
949957 | 2024-03-20T01:10:07 Z | Darren0724 | Kitchen (BOI19_kitchen) | C++17 | 24 ms | 1108 KB |
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false); cin.tie(0); #define all(x) x.begin(), x.end() #define endl '\n' #define no cout<<"Impossible"<<endl;return 0; const int N=200005; const int INF=1e9; int32_t main() { LCBorz; int n,m,k;cin>>n>>m>>k; if(m<k){ no; } vector<int> a(n),b(m); int total=0,ta=0,tb=0; for(int i=0;i<n;i++){ cin>>a[i]; if(a[i]<k){ no; } total+=a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; ta+=b[i]; } vector dp(ta+1,-INF); dp[0]=0; for(int i=0;i<m;i++){ for(int j=ta;j>=b[i];j--){ int tmp=min(b[i],n); dp[j]=max(dp[j],dp[j-b[i]]+tmp); } } for(int i=1;i<=ta;i++){ cout<<dp[i]<<' '; } cout<<endl; int ans=-1; for(int i=total;i<=ta;i++){ if(dp[i]>=k*n){ ans=i;break; } } if(ans==-1){ no; } else{ cout<<ans-total<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 1108 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |