제출 #1107617

#제출 시각아이디문제언어결과실행 시간메모리
1107617julia_08은행 (IZhO14_bank)C++17
0 / 100
2 ms592 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; int a[21], b[21]; int dp[1 << 21], sum[MAXN]; vector<int> v[MAXN]; int main(){ cin.tie(0)->sync_with_stdio(0); int n, m; 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 s=1; s<(1 << m); s++){ int bit = __builtin_ctz(s); sum[s] = sum[s ^ (1 << bit)] + b[bit]; } for(int i=0; i<n; i++){ for(int s=0; s<(1 << m); s++){ if(sum[s] == a[i]) v[i].push_back(s); } } for(int s=0; s<(1 << m); s++){ int i = dp[s] + 1; for(auto x : v[i]){ if(x & s == 0){ dp[s ^ x] = max(dp[s ^ x], i); } } } cout << (dp[(1 << m) - 1] == n - 1 ? "YES" : "NO") << "\n"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:44:22: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   44 |             if(x & s == 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...