제출 #1305830

#제출 시각아이디문제언어결과실행 시간메모리
1305830DanielPr8Kitchen (BOI19_kitchen)C++20
100 / 100
122 ms198792 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using vvl = vector<vll>; using pll = pair<ll,ll>; using vpl = vector<pll>; using vvp = vector<vpl>; #define f first #define s second #define pb push_back #define all(v) v.begin(), v.end() int main(){ ios_base::sync_with_stdio(0);cin.tie(NULL); ll n, m, k, sma=0, smb, mn=1e6; cin >> n >> m >> k; for(ll i = 0; i < n; ++i){ ll a; cin >> a; mn = min(a, mn); sma+=a; } vll b(m); for(ll& i:b){cin >> i;smb+=i;} if(mn<k){ cout << "Impossible"; return 0; } vvl dp(m+1, vll(smb+1, -1e9)); dp[0][0]=0; for(ll i = 1; i <= m; ++i){ for(ll j = 0; j <= smb; ++j){ dp[i][j] = dp[i-1][j]; if(j>=b[i-1])dp[i][j] = max(dp[i][j], dp[i-1][j-b[i-1]]+min(b[i-1],n)); } } mn = 1e9; for(ll j = sma; j <= smb; ++j){ if(dp[m][j]>=n*k){ mn=j; break; } } if(mn==1e9)cout << "Impossible"; else cout << mn-sma; }
#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...