Submission #973816

#TimeUsernameProblemLanguageResultExecution timeMemory
973816Bilal_CoderBank (IZhO14_bank)C++17
0 / 100
1 ms348 KiB
/* #include<bits/stdc++.h> using namespace std; int main() { int n , m; scanf("%d %d" , &n , &m); vector<int> a(n) , b(m); for (auto & x : a)scanf("%d" , &x); for (auto & x : b)scanf("%d" , &x); for (auto x : a){ bool flag = false; for (int mask = 0; mask < (1 << m); mask++){ int sum = 0; vector<int> v; for (int i = 0; i < m; i++) if (mask & (1 << i)){ sum += b[i]; v.push_back(b[i]); } if (sum == x){ for (auto xx : v) { auto i = find(b.begin(), b.end(), xx); *i = 0; } flag = true; break; } } if (!flag){ puts("NO"); return 0; } } puts("YES"); }*/ #include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> a(N); vector<int> b(M); for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = 0; i < M; i++) { cin >> b[i]; } for (int mask = 0; mask < (1 << M); mask++) { int sum = 0; for (int i = 0; i < M; i++) { if (mask & (1 << i)) { sum += b[i]; } } bool can_pay_all = true; for (int i = 0; i < N; i++) { if (sum < a[i]) { can_pay_all = false; break; } } if (can_pay_all) { cout << "YES" << endl; return 0; } } cout << "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...