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;
//#define int long long
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define s second
#define pi pair<int,int>
#define vii(a,n) vector<int>a(n);forn(i,n)cin>>a[i];
void solve() {
int n,m,k; cin>>n>>m>>k;
if (k-1) exit(1);
vii(a,n);
vii(b,m);
vector<int> dp(1e5,0);
dp[0]=1;
int s=0; forn(i,n) s+=a[i];
for(auto&x:b) {
for (int i=9e4; i>=0; --i) {
dp[i+x]|=dp[i];
}
}
for (int i=s; i<1e5; ++i) {
if (dp[i]) {
cout<<i-s;
return;
}
}
cout<<"Impossible";
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# | 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... |