제출 #1089155

#제출 시각아이디문제언어결과실행 시간메모리
1089155vjudge1은행 (IZhO14_bank)C++17
44 / 100
162 ms600 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 = 20 + 5; const int NN = 20; const int mod = (1e9 + 7); const int inf = 1e18; int n, m; int x[N], cols =0; void rec(int id, int l, int r, vector<int> a) { int len = r - l + 1; for (int mask = 1; mask < (1 << len); mask++) { int sum = 0; vector<int> v; for (int i = 0; i < len; i++) { if ((1 << i) & mask) { sum += a[l + i]; v.pb(l + i); } } if (sum == x[id]) { if (id == n) { cout << yes; exit(0); } for (auto pos : v) { a[pos] = 0; } sort(a.begin() + 1,a.begin() + 1 + m); rec(id + 1, l + v.sz, r, a); } } } void legenda_ne_umret() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x[i]; } vector<int> a(m + 4); for (int i = 1; i <= m; i++) { cin >> a[i]; } rec(1, 1, m, a); 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...