#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;
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]=max(dp[i-1][j], j>=x?(dp[i-1][j-x]+min(x, n)):0);
}
for (int i=sum; i<=90000; i++)
{
if (dp[m][i]>=n*k)
{
cout << i-sum;
return 0;
}
}
cout << "Impossible";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
62 ms |
92560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
14676 KB |
Output is correct |
2 |
Correct |
10 ms |
14676 KB |
Output is correct |
3 |
Correct |
10 ms |
14660 KB |
Output is correct |
4 |
Correct |
10 ms |
14664 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1364 KB |
Output is correct |
2 |
Correct |
1 ms |
1364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |