Submission #146470

#TimeUsernameProblemLanguageResultExecution timeMemory
146470Alexa2001Kitchen (BOI19_kitchen)C++17
100 / 100
28 ms760 KiB
#include <bits/stdc++.h> using namespace std; const int lim = 300; int dp[lim * lim + 10]; int n, m, k; int A[lim+2], B[lim+2]; void add(int cost, int ben) { int i; for(i=m*lim - cost; i>=0; --i) dp[i+cost] = max(dp[i+cost], dp[i] + ben); } int main() { // freopen("kitchen2.in", "r", stdin); cin.tie(0); cin.sync_with_stdio(false); cin >> n >> m >> k; int i, sum = 0; for(i=1; i<=n; ++i) cin >> A[i], sum += A[i]; for(i=1; i<=m; ++i) cin >> B[i]; for(i=1; i<=m*lim; ++i) dp[i] = -1e9; for(i=1; i<=m; ++i) add(B[i], min(n, B[i])); for(i=1; i<=n; ++i) if(A[i] < k) { cout << "Impossible\n"; return 0; } for(i=sum; i <= m*lim; ++i) if(dp[i] >= k * n) { cout << i - sum << '\n'; return 0; } cout << "Impossible\n"; 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...