제출 #657636

#제출 시각아이디문제언어결과실행 시간메모리
657636Iliya은행 (IZhO14_bank)C++17
0 / 100
1 ms368 KiB
// Freedom will be ours #include<bits/stdc++.h> #define ones(x) __builtin_popcount(x) using namespace std; typedef long long ll; typedef long double ld; const int N = 21, M = 21; int dp[1 << M], rem[1 << M], y; int high(int x){ for(int i = 20; i >= 0; i--) if(x & (1 << i)) return i; return 0; } int main(){ ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n, m; cin >> n >> m; vector<int> a(n), b(m); for(int& i : a) cin >> i; for(int& i : b) cin >> i; for(int mask = 0; mask < (1 << m); mask++){ int h = high(mask), last = dp[mask ^ (1 << h)]; int curr = rem[mask ^ (1 << h)] + b[h]; dp[mask] = last + (curr == a[last] ? 1 : 0); rem[mask] = (curr == a[last] ? 0 : curr); if(dp[mask] == n) y = 1; } cout << (y ? "YES" : "NO") << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...