Submission #499078

#TimeUsernameProblemLanguageResultExecution timeMemory
499078boykutBank (IZhO14_bank)C++14
25 / 100
1091 ms312 KiB
#include <bits/stdc++.h> using namespace std; int a[22], b[22]; int main() { ios::sync_with_stdio(0); cin.tie(0); srand(time(NULL)); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; sort(b, b + m); do { int s = 0; int j = 0; for (int i = 0; i < m && j < n; i++) { s += b[i]; if (s > a[j]) break; if (s == a[j]) { s = 0; j++; } } if (j == n) { return cout << "YES\n", 0; } } while (next_permutation(b, b + m)); 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...