제출 #438796

#제출 시각아이디문제언어결과실행 시간메모리
438796jalsol은행 (IZhO14_bank)C++17
0 / 100
5 ms4440 KiB
#ifdef LOCAL #include <local.h> #else #include <bits/stdc++.h> #define debug(...) #endif const int maxn = 20; int n, m; int a[maxn]; int b[maxn]; int dp[1 << maxn]; int go(int i, int mask, int sum) { if (i >= n) return true; int &ret = dp[mask]; if (ret != -1) return ret; for (int j = 0; j < m; j++) { if (mask >> j & 1) continue; if (sum + b[j] == a[i]) { if (go(i + 1, mask | (1 << j), 0)) { return ret = true; } } else if (sum + b[j] < a[i]) { if (go(i, mask | (1 << j), sum + b[j])) { return ret = true; } } } return ret = false; } signed main() { #ifndef LOCAL freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); #endif std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cin >> n >> m; for (int i = 0; i < n; i++) { std::cin >> a[i]; } for (int i = 0; i < m; i++) { std::cin >> b[i]; } std::fill_n(dp, 1 << maxn, -1); std::cout << (go(0, 0, 0) ? "YES" : "NO") << '\n'; return 0; }

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

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