Submission #1113680

#TimeUsernameProblemLanguageResultExecution timeMemory
1113680ChinguunBank (IZhO14_bank)C++14
19 / 100
6 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N = 27; const int oo = 1e18; const int mod = 1e9 + 7; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; int a[N], b[N], n, m; bool f; void sol (int i, int k) { if (i > n) { f = 1; return; } if (k > m) return; if (a[i] < b[k]) return; if (a[i] == b[k]) { sol (i + 1, k + 1); } else { a[i] -= b[k]; sol (i, k + 1); a[i] += b[k]; sol (i, k + 1); } return; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> b[i]; sort (a + 1, a + n + 1); sort (b + 1, b + m + 1); sol (1, 1); if (f) cout << "YES\n"; else 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...