Submission #824319

#TimeUsernameProblemLanguageResultExecution timeMemory
824319christinelynnBank (IZhO14_bank)C++17
19 / 100
9 ms324 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long void print(string Z) { cout << Z << endl; } ll arr[23]; ll arr2[23]; ll ps[23]; bool flag[23]; ll N, M; bool check(ll idx, ll nd, ll ret) { if(ret == nd) { flag[idx-1] = 1; check(0, nd-arr2[idx-1], ret); return 1; } else if(flag[idx]) { return check(idx+1, nd, ret); } else if(idx > M || ret > nd) { return 0; } else { return (check(idx+1, nd, ret+arr2[idx]) || check(idx+1, nd, ret)); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M; for(int i=0; i<N; i++) { cin >> arr[i]; } for(int i=0; i<M; i++) { cin >> arr2[i]; if(i == 0) { ps[i] = arr2[i]; } else { ps[i] = ps[i-1] + arr2[i]; } } sort(arr2, arr2+M); bool X = 1; for(int i=0; i<N; i++) { X = X && check(0, arr[i], 0); } if(X) { print("YES"); } else { print("NO"); } 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...