#include <bits/stdc++.h>
using namespace std;
int dp[305][90005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, k, sum=0, ans=1e9;
cin >> n >> m >> k;
for (int i=1; i<=n; i++)
{
int x;
cin >> x;
if (x<k)
{
cout << "Impossible";
return 0;
}
sum+=x;
}
for (int i=1; i<=90000; i++)
dp[0][i]=1e9;
for (int i=1; i<=m; i++)
{
int x;
cin >> x;
for (int j=0; j<=90000; j++)
dp[i][j]=min(dp[i-1][j], j>=min(x, n)?(dp[i-1][j-min(x, n)]+x):(int)1e9);
}
for (int i=n*k; i<=90000; i++)
ans=min(ans, dp[m][i]-sum);
if (ans>5e8)
cout << "Impossible";
else
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
59 ms |
92592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14664 KB |
Output is correct |
2 |
Correct |
11 ms |
14656 KB |
Output is correct |
3 |
Incorrect |
10 ms |
14664 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |