This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |