Submission #1089385

#TimeUsernameProblemLanguageResultExecution timeMemory
1089385vjudge1Bank (IZhO14_bank)C++17
100 / 100
199 ms104104 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define sz size() #define yes "YES" #define no "NO" #define IOI ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pf push_front #define pb push_back #define S second #define F first using namespace std; const int N = 200 + 5; const int NN = 1e5; const int mod = (1e9 + 7); const int inf = 1e18; int a[N], x[N], used[22][2222222]; int n, m; vector<int> g[1111]; void rec(int pos, int mask) { if (pos == n + 1) { cout << yes; exit(0); } if (used[pos][mask]) return; used[pos][mask] = 1; for (auto& cur : g[x[pos]]) { if (cur & mask) { continue; } rec(pos + 1, cur | mask); } } void legenda_ne_umret() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x[i]; } for (int i = 1; i <= m; i++) { cin >> a[i]; } for (int mask = 1; mask < (1 << m); mask ++) { int sum = 0; for (int i = 0; i < m; i++) { if ((1 << i) & mask) { sum += a[i + 1]; } } if (sum <= 1000) { g[sum].pb(mask); } } rec(1, 0); cout << no; } signed main() { IOI; // freopen("maze.in", "r", stdin); // freopen("maze.out", "w", stdout); ///////////////////////////////////////////// int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { // cout << "Case " << i << ":\n"; legenda_ne_umret(); cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...