제출 #1107273

#제출 시각아이디문제언어결과실행 시간메모리
1107273vjudge1은행 (IZhO14_bank)C++17
52 / 100
59 ms4576 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, ps[maxn]; 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 = ps[mask]; if(mask & mm) continue; 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]; for(int mask = 0; mask < (1 << m); mask++){ int sum = 0; for(int i = 0; i < m; i++){ if(mask >> i & 1) sum += b[i]; } ps[mask] = sum; } f(0, 0); cout << (ok? "YES":"NO"); }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'void f(int, int)':
bank.cpp:17:13: warning: unused variable 'brk' [-Wunused-variable]
   17 |         int brk = 0, sum = ps[mask];
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...