Submission #974049

#TimeUsernameProblemLanguageResultExecution timeMemory
974049Art_ogoBank (IZhO14_bank)C++17
19 / 100
83 ms8540 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define ve vector #define all(x) x.begin(), x.end() #define pb(x) push_back(x) using namespace std; mt19937 rnd; typedef pair<ll, ll> pll; typedef pair<int, int> pii; void solve(){ int n, m; cin >> n >> m; ve<int> a(n); ve<int> b(m); for(auto& i : a) cin >> i; for(auto& j : b) cin >> j; ve<int> cur(1 << m, 0); ve<int> lefts(1 << m, 0); for(int i = 1; i < (1 << m); i++){ int mxi = -1; for(int j = 0; j < m; j++){ if(((i >> j) & 1) && (mxi == -1 || cur[i ^ (1 << j)] > cur[mxi])) mxi = j; } cur[i] = cur[i ^ (1 << mxi)]; lefts[i] = lefts[i ^ (1 << mxi)] + b[mxi]; if(lefts[i] == a[cur[i]]){ cur[i]++; lefts[i] = 0; } if(cur[i] == n){ cout << "YES"; return; } } cout << "NO"; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int T = 1; // cin >> T; while(T--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...