Submission #514902

#TimeUsernameProblemLanguageResultExecution timeMemory
514902MahdiKitchen (BOI19_kitchen)C++17
20 / 100
2 ms340 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...