#include <bits/stdc++.h>
using namespace std;
const int nx=305;
int n, m, k, sm, x, dp[nx][nx*nx], c, ans=INT_MAX;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>k;
for (int i=1; i<=n; i++) cin>>x, sm+=x, c|=(x<k);
for (int i=0; i<=n; i++) for (int j=1; j<nx*nx; j++) dp[i][j]=INT_MIN;
for (int i=1; i<=m; i++)
{
cin>>x;
for (int j=0; j+x<nx*nx; j++)
{
dp[i][j+x]=max(dp[i][j+x], dp[i-1][j]+min(x, n));
if (dp[i][j+x]>=n*k&&j+x>=sm) ans=min(ans, j+x-sm);
}
//for (int j=0; j<20; j++) cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
}
if (ans==INT_MAX||c) cout<<"Impossible";
else cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Correct |
24 ms |
111312 KB |
Output is correct |
6 |
Correct |
2 ms |
7000 KB |
Output is correct |
7 |
Correct |
2 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Correct |
24 ms |
111312 KB |
Output is correct |
6 |
Correct |
2 ms |
7000 KB |
Output is correct |
7 |
Correct |
2 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Incorrect |
3 ms |
6236 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
109144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
15196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
2 ms |
6748 KB |
Output is correct |
5 |
Correct |
24 ms |
111312 KB |
Output is correct |
6 |
Correct |
2 ms |
7000 KB |
Output is correct |
7 |
Correct |
2 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Incorrect |
3 ms |
6236 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |