제출 #1047618

#제출 시각아이디문제언어결과실행 시간메모리
1047618manhlinh1501은행 (IZhO14_bank)C++17
52 / 100
1099 ms20828 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 21; #define ALL(a) (a).begin(), (a).end() int N, M; int a[MAXN]; int b[MAXN]; namespace subtask { vector<int> g[MAXN]; bool dp[MAXN][1 << MAXN]; void solution() { for(int i = 1; i <= N; i++) { for(int mask = 0; mask < (1 << M); mask++) { int res = 0; for(int j = 0; j < M; j++) { if(mask >> j & 1) res += b[j + 1]; } if(res == a[i]) g[i].emplace_back(mask); } } dp[0][0] = true; for(int i = 1; i <= N; i++) { if(g[i].empty()) return cout << "NO", void(0); for(int j : g[i]) { for(int mask = 0; mask < (1 << M); mask++) { if(dp[i - 1][mask] == false) continue; if((mask & j) == 0) { // cout << i << " " << mask << " " << j << "\n"; dp[i][mask ^ j] = true; } } } } for(int mask = 0; mask < (1 << M); mask++) { if(dp[N][mask]) return cout << "YES", void(0); } cout << "NO"; exit(0); } } signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M; for(int i = 1; i <= N; i++) cin >> a[i]; for(int i = 1; i <= M; i++) cin >> b[i]; if(accumulate(a + 1, a + N + 1, 0) > accumulate(b + 1, b + M + 1, 0)) return cout << "NO", 0; subtask::solution(); return (0 ^ 0); }

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

bank.cpp: In function 'int main()':
bank.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(TASK ".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...