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>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
const int N=305;
int n, m, k, a[N], b[N], c[N*N];
bitset<N*N>e;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>k;
for(int i=0;i<n;++i)
cin>>a[i];
int z=0;
for(int i=0;i<m;++i){
cin>>b[i];
z+=b[i];
}
e.set(0);
for(int i=0;i<m;++i)
e|=(e<<b[i]);
int x=0;
for(int i=0;i<n;++i)
x+=a[i];
for(int i=x;i<=z;++i){
if(e.test(i)){
cout<<i-x;
return 0;
}
}
cout<<"Impossible";
}
# | 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... |