Submission #1107265

#TimeUsernameProblemLanguageResultExecution timeMemory
1107265vjudge1Bank (IZhO14_bank)C++17
71 / 100
1068 ms592 KiB
#include <bits/stdc++.h> // #define int long long using namespace std; const int N = 1e5 + 11; const int maxn = 1e6 + 11; const int inf = 1e9 + 7; const int MOD = 1e9 + 7; int n, m, a[N], b[N], ok = 0; void f(int pos, int mm){ if(pos == n + 1) ok = 1; if(ok) { return; } for(int mask = 0; mask < (1 << m); mask++){ int brk = 0, sum = 0; if(mask & mm) continue; for(int i = 0; i < m; i++){ if(mask >> i & 1) sum += b[i]; } if(sum == a[pos]) f(pos + 1, (mask | mm)); if(ok){ return; } } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; f(0, 0); cout << (ok? "YES":"NO"); }

Compilation message (stderr)

bank.cpp: In function 'void f(int, int)':
bank.cpp:17:13: warning: unused variable 'brk' [-Wunused-variable]
   17 |         int brk = 0, sum = 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...