#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=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<10; j++) cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
}
if (ans==INT_MAX||c) cout<<"Impossible";
else cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
95360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
14940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |