제출 #1099277

#제출 시각아이디문제언어결과실행 시간메모리
1099277vjudge1Kitchen (BOI19_kitchen)C++17
100 / 100
75 ms108648 KiB
#include <bits/stdc++.h> #define ll int using namespace std; #define bit(x,y) ((x >> y) & 1) const ll mod = 1e9 + 7; const ll inf = INT_MIN/2; ll d[305][305 * 305]; ll a[305],b[305]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n,m,k; cin >> n >> m >> k; ll i,j; ll s = 0; for(i = 1;i <= n;i++) { cin >> a[i]; s += a[i]; } for(i = 1;i <= m;i++) cin >> b[i]; for(i = 1;i <= n;i++) { if(a[i] < k) { cout << "Impossible"; return 0; } } for(i = 0;i <= 300;i++) { for(j = 0;j <= 300 * 300;j++) { d[i][j] = inf; } } d[0][0] = 0; for(i = 1;i <= m;i++) { for(j = 0;j <= 300 * 300;j++) { if(d[i - 1][j] == inf) continue; d[i][j] = max(d[i][j],d[i - 1][j]); if(j + b[i] <= 300 * 300) d[i][j + b[i]] = max(d[i][j + b[i]],d[i - 1][j] + min(b[i],n)); } } ll ans = -1; for(i = s;i <= 300 * 300;i++) { if(d[m][i] >= n * k) { ans = i - s; break; } } if(ans == -1) cout << "Impossible"; else cout << ans; }
#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...