#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
const int M = 6e4 + 5;
bool dp[M] = {};
void add(int x)
{
for(int i = M-1; i >= x; i--)
{
if(dp[i-x])
dp[i] = 1;
}
}
int main()
{
int n, m, k;
cin >> n >> m >> k;
int meal[n], chef[m];
dp[0] = 1;
long long sum = 0;
for(int i = 0; i < n; i++)
{
cin >> meal[i];
sum += meal[i];
}
for(int i = 0; i < m; i++)
{
cin >> chef[i];
add(chef[i]);
}
bool check = false;
long long ans = 0;
for(int i = sum; i < M; i++)
{
if(dp[i])
{
check = true;
ans = i-sum;
break;
}
}
if(check)
cout << ans;
else
cout << "Impossible";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
340 KB |
Output is correct |
2 |
Correct |
11 ms |
316 KB |
Output is correct |
3 |
Correct |
15 ms |
328 KB |
Output is correct |
4 |
Incorrect |
14 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |