This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 305;
const int maxsum = maxn * maxn;
int n, m, k;
int a[maxn];
int b[maxn];
bitset<maxsum> dp;
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
for (int i = 1; i <= m; ++i)
{
cin >> b[i];
}
dp[0] = true;
for (int i = 1; i <= m; ++i)
{
dp |= (dp << b[i]);
}
int target = 0;
for (int i = 1; i <= n; ++i)
{
target += a[i];
}
for (int i = target; i < maxsum; ++i)
{
if (dp[i] == true)
{
cout << i - target << endl;
return 0;
}
}
cout << "Impossible" << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |