제출 #871942

#제출 시각아이디문제언어결과실행 시간메모리
871942chuongdan은행 (IZhO14_bank)C++14
0 / 100
3 ms2396 KiB
#include <bits/stdc++.h> #define N 20 #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i, l, r) for(int i = l; i <= r; i++) #define rep2(i, l, r) for(int i = r; i >= l; i--) using namespace std; typedef pair<int,int> ii; typedef pair<ii,int> iii; typedef pair<ii, ii> iv; typedef unsigned long long ull; const int MOD = 1e9 + 7; const int inf = 1e9; const bool multi_test = false; const string NAME = "bank"; int exp(int x, int y){ int res = 1; while (y){ if (y & 1) res = res * x % MOD; x = x * x % MOD; y >>= 1; } return res; } int n, m; int a[N+5], b[N+5]; bool dp[N+5][(1<<N)+5]; int sum_mask[(1<<N)+5]; void solve(){ cin >> n >> m; rep(i, 1, n) cin >> a[i]; rep(i, 1, m) cin >> b[i]; rep(mask, 1, (1<<m) - 1){ rep(i, 1, m){ if ((mask >> (i-1)) & 1) sum_mask[mask] += b[i]; } } dp[0][0] = 1; rep(i, 1, n){ rep(mask, 0, (1<<m) - 1){ for(int mask2 = mask; mask2; mask2 = (mask2 - 1) & mask){ int k = mask ^ mask2; if (dp[i-1][mask2] && sum_mask[k] == a[i]){ dp[i][mask] = 1; } } if (sum_mask[mask] == a[i] && dp[i-1][0]) dp[i][mask] = 1; // cout << i << " " << mask << " " << dp[i][mask] << endl; } } bool ac = false; rep(mask, 1, (1<<m) - 1){ if (dp[n][mask]) ac = true; } if (ac) cout << "YES"; else cout << "NO"; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); // #ifndef ONLINE_JUDGE freopen((NAME + ".in").c_str(), "r", stdin); freopen((NAME + ".out").c_str(), "w", stdout); // #endif // ONLINE_JUGDE int t = 1; if (multi_test) cin >> t; while (t--) solve(); }

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

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