제출 #657640

#제출 시각아이디문제언어결과실행 시간메모리
657640Iliya은행 (IZhO14_bank)C++17
19 / 100
180 ms12612 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], mark[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; mark[0] = 1; for(int mask = 0; mask < (1 << m); mask++){ for(int i = 0; i < m; i++){ if(mark[mask ^ (1 << i)] and (mask & (1 << i))){ int last = dp[mask ^ (1 << i)]; int curr = rem[mask ^ (1 << i)] + b[i]; dp[mask] = last + (curr == a[last] ? 1 : 0); rem[mask] = (curr == a[last] ? 0 : curr); mark[mask] = 1; } } 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...