제출 #1104797

#제출 시각아이디문제언어결과실행 시간메모리
1104797detective_dots은행 (IZhO14_bank)C++17
19 / 100
1 ms504 KiB
#include <bits/stdc++.h> #define int long long #define ll long long #define ld long double #define ull unsigned long long #define endl '\n' #define NF string::npos #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() #define FAST ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) using namespace std; const int N = 1e7 + 5; const int mod = 1e9 + 7; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; signed main() { FAST; int n, m; cin >> n >> m; vector <int> a(n); multiset <int, greater <int> > st1, st2; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) { int x; cin >> x; st1.insert(x); } bool ok = 1; for(int i = 0; i < n; i++) { bool x = 0; for(auto it = st1.begin(); it != st1.end(); it++) { int z = 0; if(z + *it <= a[i]) { for(auto it2 = it; it2 != st1.end(); it2++) { if(z + *it2 <= a[i]) z += *it2; else st2.insert(*it2); } } if(z == a[i]) { x = 1; break; } st2.clear(); } if(!x) { ok = 0; break; } st1 = st2; st2.clear(); } cout << (ok ? "YES" : "NO") << endl; 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...