Submission #771759

#TimeUsernameProblemLanguageResultExecution timeMemory
771759teo_thrashKitchen (BOI19_kitchen)C++14
30 / 100
27 ms12852 KiB
#include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; const int maxn=1e6+3; const int mod=1e9+7; int n, m, k, a[320], b[320]; int dp[320][10003]; ll a_sum=0, b_sum=0; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>m>>k; for(int i=1; i<=n; i++){ cin>>a[i]; if(a[i]<k){ cout<<"Impossible"; return 0; } a_sum+=a[i]; } for(int i=1; i<=m; i++){ cin>>b[i]; b_sum+=b[i]; } memset(dp, -1, sizeof(dp)); dp[0][0]=0; for(int i=1; i<=m; i++){ for(int j=0; j<=b_sum; j++){ dp[i][j]=dp[i-1][j]; if(b[i]<=j){ dp[i][j]=max(dp[i][j], dp[i-1][j-b[i]]+min(n, b[i])); } } } int ans=INT_MAX; for(int j=a_sum; j<=b_sum; j++){ if(dp[m][j]>=n*k){ cout<<j-a_sum<<endl; return 0; } } cout<<"Impossible"; return 0; }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:54:5: warning: unused variable 'ans' [-Wunused-variable]
   54 | int ans=INT_MAX;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...