#include <bits/stdc++.h>
using namespace std;
const int nx=305;
int n, m, k, sm, x, dp[nx*nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>k;
for (int i=1; i<=n; i++) cin>>x, sm+=x;
dp[0]=1;
for (int i=1; i<=m; i++)
{
cin>>x;
for (int j=nx*nx-x-1; j>=0; j--) dp[j+x]|=dp[j];
}
for (int i=sm; i<nx*nx; i++)
{
if (dp[i])
{
cout<<i-sm;
return 0;
}
}
cout<<"Impossible";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
604 KB |
Output is correct |
2 |
Correct |
10 ms |
604 KB |
Output is correct |
3 |
Correct |
13 ms |
820 KB |
Output is correct |
4 |
Correct |
13 ms |
824 KB |
Output is correct |
5 |
Correct |
12 ms |
824 KB |
Output is correct |
6 |
Correct |
9 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |