제출 #1122339

#제출 시각아이디문제언어결과실행 시간메모리
1122339TAFH은행 (IZhO14_bank)C++17
0 / 100
2 ms464 KiB
#include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < n; i++) #define ull unsigned long long #define ll long long #define SPEED \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) using namespace std; const int N = 4e5 + 13; const int maxa = 2e5 + 13; const ll mod = 1e9 + 7; using tp = tuple<ll, ll, ll>; const int mxn = 30; void prestart() {} void start() { int n, m; cin >> n >> m; int a[n], b[m]; forn(i, n) cin >> a[i]; forn(i, m) cin >> b[i]; int covered[(1 << m)]; int left[(1 << m)]; fill(covered, covered + (1 << m), -1); fill(left, left + (1 << m), -1); covered[0] = 0; left[0] = 0; for(int s = 0; s < (1 << m); s++) { for(int i = 0; i < m; i++) { if (s & (1 << i) == 0) continue; int prev = s ^ (1 << i); if (covered[prev] == -1) continue; if (a[covered[prev]] > left[prev] + b[i]) { covered[s] = covered[prev]; left[s] = left[prev] + b[i]; } else if (left[prev] + b[i] == a[covered[prev]]) { covered[s] = covered[prev] + 1; left[s] = 0; } } } for(int s = 0; s < (1 << m); s++) { if (covered[s] == n) { cout << "Yes" << "\n"; return; } } cout << "No" << "\n"; } signed main() { SPEED; int t = 1; prestart(); // cin >> t; while (t--) { start(); } }

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

bank.cpp: In function 'void start()':
bank.cpp:39:30: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   39 |             if (s & (1 << i) == 0) continue;
      |                     ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...