Submission #1089479

#TimeUsernameProblemLanguageResultExecution timeMemory
1089479vjudge1Bank (IZhO14_bank)C++17
100 / 100
225 ms104700 KiB
/* * imaN * 49 * **/ #include <bits/stdc++.h> using namespace std; //#define ll long long #define FF first #define SS second #define pb push_back #define bp pop_back() #define int long long #define ld long double #define pf push_front #define Imansoska ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0); #define endl cout << "\n" #define all(x) x.begin(),x.end() #define lb lower_bound /*int binpow (int a, int n, int m) { if (n == 0) return 1%m; if (n % 2 == 1) return binpow (a, n-1,m) * a%m; else { int b = binpow (a, n/2,m); return b * b%m; } } int lcm(int a, int b) { return (a / __gcd(a, b)) * b; }*/ const int N = (1e5+13); const int maxn= 1e6+100; const int MOD = 1e9 + 7; const int INF = 1e18 + 7; int a[210],b[210],used[22][2222222]; vector <int> g[1010]; int n,k; void rec(int pos,int msk) { if ( pos==n+1 ) { cout << "YES"; exit(0); } if ( used[pos][msk] ) return; used[pos][msk]=1; for ( auto cur : g[a[pos]] ) { if ( cur & msk ) { continue; } rec(pos+1,cur | msk); } } signed main (/*Imansoska*/) { // Imansoska// freopen("lepus.in","r",stdin); // freopen("lepus.out","w",stdout); cin >> n >> k; for ( int i=1; i<=n; i++ ) { cin >> a[i]; } for ( int i=1; i<=k; i++ ) { cin >> b[i]; } for ( int mask=1; mask< (1 << k); mask++ ) { int sum=0; for ( int i=0; i<k; i++ ) { if ( (1 << i) & mask ) { sum+=b[i+1]; } } if ( sum<=1000 ) { g[sum].pb(mask); } } rec(1,0); cout << "NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...