#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; ++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 |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |