제출 #683691

#제출 시각아이디문제언어결과실행 시간메모리
683691oblantis은행 (IZhO14_bank)C++17
19 / 100
112 ms8500 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int inf = 1e9; const int mod = 1e9 + 7; const int maxn = 2e5 + 12; void solve() { int n, m; cin >> n >> m; int a[n + 1], b[m], rs[1 << m], ind[1 << m]; a[n] = inf; rs[0] = ind[0] = 0; for(int i = 1; i < (1 << m); i++) ind[i] = rs[i] = -1; for(int i = 0; i < n; i++) { cin >> a[i]; } for(int i = 0; i < m; i++) { cin >> b[i]; } bool ok = 0; for(int i = 0; i < (1 << m); i++) { for(int j = 0; j < m; j++) { if(i & (1 << j)) { continue; } if(ind[i] == n)ok = 1; if(ind[i] == -1)continue; int now = a[ind[i]] - rs[i] - b[j]; if(now == 0){ rs[i | (1 << j)] = 0, ind[i | (1 << j)] = ind[i] + 1; } else if(now > 0)rs[i | (1 << j)] = rs[i] + b[j], ind[i | (1 << j)] = ind[i]; } } if(ok)cout << "YES"; else cout << "NO"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tcs = 1; //cin >> tcs; for(int i = 1; i <= tcs; i++) { solve(); } 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...