제출 #848009

#제출 시각아이디문제언어결과실행 시간메모리
848009_hbk06은행 (IZhO14_bank)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> using namespace std; const int mxN = 5e5 + 5; #define int long long #define MASK(n) (1 << (n)) #define BIT(mask,x) ((mask >> x) & 1) const long long infll = 1e18 + 69; int n; int m; int a[20]; int b[20]; int s[MASK(20)]; bool dp[MASK(20)][20]; signed main () { freopen("bank.in","r",stdin); freopen("bank.out","w",stdout); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; for (int mask = 0; mask < MASK(m); mask++) for (int j = 0; j < m; j++) if(BIT(mask,j)) s[mask] += b[j]; dp[0][0] = 1; for (int mask = 0; mask < MASK(m); mask++) for (int sub = mask; sub; sub = (sub - 1) & mask) for (int i = 1; i <= n; i++) { if(s[sub] == a[i] && dp[mask ^ sub][i - 1]) dp[mask][i] = true; } bool kt = false; for (int mask = 0; mask < MASK(m); mask++) if(dp[mask][n]) {kt = true;break;} if(kt) cout << "YES" << "\n"; else cout << "NO" << "\n"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("bank.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("bank.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...