제출 #1220247

#제출 시각아이디문제언어결과실행 시간메모리
1220247jellybeanKitchen (BOI19_kitchen)C++20
100 / 100
136 ms215324 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define dd(x) cout<<#x<<" is "<<x<<endl; #define dl(x) cout<<#x<<" is "; for(auto i:x) cout<<i<<' '; cout<<endl; typedef pair<int,int> pii; const int N = 305, M = 305; int dp[M][90005], a[N], b[M]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,m,k; cin>>n>>m>>k; int tot = 0; for(int i=1; i<=n; i++) cin>>a[i], tot+=a[i]; for(int i=1; i<=m; i++) cin>>b[i]; if(m<k) {cout<<"Impossible"; return 0;} for(int i=1; i<=n; i++){ if(a[i] < k) {cout<<"Impossible"; return 0;} } memset(dp,-1,sizeof(dp)); dp[0][0] = 0; for(int i=1; i<=m; i++){ for(int j=0; j<90005; j++){ dp[i][j] = dp[i-1][j]; if(j-b[i]>=0 and dp[i-1][j-b[i]] != -1){ dp[i][j] = max(dp[i][j], dp[i-1][j-b[i]] + min(b[i],n)); } } } int ans = LLONG_MAX; for(int i=tot; i<90005; i++){ if(dp[m][i] >= n*k) {ans = i-tot; break;} } if(ans == LLONG_MAX) cout<<"Impossible"; else cout<<ans; 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...