제출 #1133329

#제출 시각아이디문제언어결과실행 시간메모리
1133329enzyKitchen (BOI19_kitchen)C++20
0 / 100
66 ms99652 KiB
#include <bits/stdc++.h> using namespace std; const int maxn=310; int v[maxn], dp[maxn][maxn*maxn], pd[maxn][maxn*maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m, k; cin >> n >> m >> k; int sum=0; for(int i=1;i<=n;i++){ int a; cin >> a; sum+=a; if(a<k){ cout << "Impossible" << endl; return 0; } } pd[0][0]=1; for(int i=1;i<=m;i++) cin >> v[i]; for(int i=1;i<=m;i++){ for(int j=0;j<v[i];j++) dp[i][j]=dp[i-1][j]; for(int j=0;j<maxn*maxn-v[i];j++){ if(pd[i-1][j]){ dp[i][j+v[i]]=max(dp[i-1][j+v[i]],dp[i-1][j]+min(v[i],n)); pd[i][j+v[i]]=1; }else dp[i][j+v[i]]=dp[i-1][j+v[i]]; } } for(int i=sum;i<maxn*maxn;i++){ if((dp[m][i]/n)>=k){ cout << i-sum << endl; return 0; } } cout << "Impossible" << endl; return 0; }
#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...