제출 #710812

#제출 시각아이디문제언어결과실행 시간메모리
710812MinaRagy06은행 (IZhO14_bank)C++17
100 / 100
680 ms172776 KiB
#include <bits/stdc++.h> using namespace std; #define lesgooo ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define endl '\n' #define int long long int a[25], b[25]; int dp[21][1 << 20]; int n, m; bool solve(int lvl, int msk, int rem, int i); bool solve(int i, int j) { if (i == n) return 1; if (~dp[i][j]) return dp[i][j]; return dp[i][j] = solve(i, j, a[i], 0); } bool solve(int lvl, int msk, int rem, int i) { if (i == m) { if (rem == 0) return solve(lvl+1, msk); return 0; } return ((msk | (1 << i)) != msk && rem-b[i] >= 0? solve(lvl, msk | (1 << i), rem-b[i], i+1): 0) || solve(lvl, msk, rem, i+1); } signed main() { lesgooo; memset(dp, -1, sizeof dp); cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; sort(b, b+m); reverse(b, b+m); cout << (solve(0, 0)? "YES" : "NO"); return 0; }

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

bank.cpp: In function 'bool solve(long long int, long long int)':
bank.cpp:17:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   17 |     return dp[i][j] = solve(i, j, a[i], 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...