제출 #859522

#제출 시각아이디문제언어결과실행 시간메모리
859522overwatch9은행 (IZhO14_bank)C++17
44 / 100
1075 ms596 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, m; cin >> n >> m; vector <int> sums(n); for (int i = 0; i < n; i++) cin >> sums[i]; vector <int> notes(m); for (int i = 0; i < m; i++) cin >> notes[i]; if (n == 1) { for (int i = 0; i < (1 << m); i++) { int s = 0; for (int j = 0; j < m; j++) { if (i & (1 << j)) s += notes[j]; } if (s == sums[0]) { cout << "YES\n"; return 0; } } cout << "NO\n"; return 0; } else { sort(notes.begin(), notes.end()); do { int p = 0, tot = 0; for (int i = 0; i < m && p < n; i++) { tot += notes[i]; if (tot == sums[p]) { p++; tot = 0; } else if (tot > sums[p]) break; } if (p >= n) { cout << "YES\n"; return 0; } } while (next_permutation(notes.begin(), notes.end())); cout << "NO\n"; 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...