#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++)
if (dp[m][i]>=sum)
ans=min(ans, dp[m][i]-sum);
if (ans>5e8)
cout << "Impossible";
else
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
92508 KB |
Output is correct |
2 |
Correct |
50 ms |
80200 KB |
Output is correct |
3 |
Correct |
66 ms |
106348 KB |
Output is correct |
4 |
Correct |
67 ms |
106276 KB |
Output is correct |
5 |
Correct |
64 ms |
102752 KB |
Output is correct |
6 |
Correct |
46 ms |
73804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
14708 KB |
Output is correct |
2 |
Correct |
13 ms |
14760 KB |
Output is correct |
3 |
Correct |
11 ms |
14768 KB |
Output is correct |
4 |
Correct |
12 ms |
14708 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |