제출 #1101853

#제출 시각아이디문제언어결과실행 시간메모리
1101853vjudge1은행 (IZhO14_bank)C++17
0 / 100
4 ms16888 KiB
#include <bits/stdc++.h> // #define int long long #define ll long long #define f first #define s second #define LSOne(s) ((s) & -(s)) using namespace std; typedef pair<int, int> pii; typedef tuple<int, int, int> iii; int mod = 1e9 + 7; const int mx9 = 1e9 + 1; const int mx6 = 1e6 + 1; const int maxn = 21; const int maxc = 1002; vector<pii> dp((1 << maxn), {0, 0}); vector<int> salaries(maxn), banknotes(maxn); int n, m; void solve() { cin >> n >> m; bool ans = false; for (int x = 0; x < n; x++) { cin >> salaries[x]; } for (int y = 0; y < m; y++) { cin >> banknotes[y]; } for (int mask = 0; mask < (1 << m); mask++) { if (ans) break; for (int pos = 0; pos < m; pos++) { if (mask & (1 << pos) >= 1) continue; int idx = dp[mask].s; int currentval = dp[mask].f; if (idx < n) { if (currentval + banknotes[pos] == salaries[idx]) { idx++; currentval = 0; dp[mask | (1 << pos)] = max(dp[mask | (1 << pos)], make_pair(currentval, idx)); if (idx == n) { ans = true; break; } } else if(currentval + banknotes[pos] < salaries[idx]) { currentval += banknotes[pos]; dp[mask | (1 << pos)] = max(dp[mask | (1 << pos)], make_pair(currentval, idx)); } } } } ans ? cout << "YES" : cout << "NO"; } signed main() { // freopen("movie.in", "r", stdin); // freopen("movie.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { solve(); } return 0; }

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

bank.cpp: In function 'void solve()':
bank.cpp:36:35: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   36 |             if (mask & (1 << pos) >= 1)
      |                        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...