Submission #1099270

#TimeUsernameProblemLanguageResultExecution timeMemory
1099270vjudge1Kitchen (BOI19_kitchen)C++17
0 / 100
69 ms107604 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() { 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 = 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; } 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...