#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 = 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 time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
108624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
108624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
108624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
108624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
108624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |