제출 #858793

#제출 시각아이디문제언어결과실행 시간메모리
858793phongcd은행 (IZhO14_bank)C++14
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define ii pair <int, int> #define ill pair <ll, ll> #define ild pair <ld, ld> #define fi first #define se second #define all(x) x.begin(), x.end() #define file "test" using namespace std; const int N = 22; const ll MOD = 998244353; const ll INF = 1e18; const ll base = 311; const int BLOCK_SIZE = 400; int n, m; int a[N], b[N], f[N][1 << N]; vector <int> h[1002]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen(file".inp","r",stdin); freopen(file".out","w",stdout); #endif cin >> n >> m; int ma = 0; for (int i = 1; i <= n; i ++) cin >> a[i], ma = max(ma, a[i]); for (int i = 0; i < m; i ++) cin >> b[i]; for (int s = 1; s < (1 << m); s ++) { int sum = 0; for (int j = 0; (1 << j) <= s; j ++) if (s >> j & 1) sum += b[j]; if (sum <= ma) h[sum].push_back(s); } f[0][0] = 1; for (int i = 1; i <= n; i ++) for (int s = 0; s < (1 << m); s ++) { if (!f[i - 1][s]) continue; for (int j: h[a[i]]) if ((s & j) == 0) f[i][s | j] = 1; } for (int j = 1; j < (1 << m); j ++) if (f[n][j]) { cout << "YES"; return 0; } cout << "NO"; } /* /\_/\ zzZ (= -_-) / >u >u */

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

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