Submission #973740

#TimeUsernameProblemLanguageResultExecution timeMemory
973740Bilal_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; for (int i = 0; i < m; i++) if (mask & (1 << i))sum += b[i]; if (sum == x){ flag = true; break; } } if (!flag){ puts("nO"); return 0; } } puts("YES"); }*/ #include <bits/stdc++.h> using namespace std; string solve(int n, int m, vector<int>& a, vector<int>& b) { sort(a.begin(), a.end()); sort(b.begin(), b.end()); for (int i = 0; i < n; i++) { int ind = -1; for (int j = 0; j < m; j++) { if (b[j] <= a[i]) { ind = j; } else { break; } } if (ind == -1) { return "nO"; } b.erase(b.begin() + ind); m--; } return "YES"; } 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]; } cout << solve(n, m, a, b) << 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...