제출 #1087813

#제출 시각아이디문제언어결과실행 시간메모리
1087813quangminh412은행 (IZhO14_bank)C++14
71 / 100
1075 ms41300 KiB
#include <bits/stdc++.h> using namespace std; /* John Watson https://codeforces.com/profile/quangminh98 Mua Code nhu mua Florentino !! */ #define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long const int maxn = 30; int n, m; int a[maxn], b[maxn], s[1 << 21]; signed main() { if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } faster(); cin >> n >> m; int full = (1 << m); for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> b[i]; for (int mask = 0; mask < full; mask++) { int sum = 0; for (int i = 0; i < m; i++) if (mask >> i & 1) sum += b[i + 1]; s[mask] = sum; } vector<vector<int>> dp(n + 5, vector<int>(full + 5, 0)); vector<int> pos[maxn]; // base case for (int mask = 0; mask < full; mask++) { int sum = 0; for (int i = 0; i < m; i++) if (mask >> i & 1) sum += b[i + 1]; if (sum == a[1]) { dp[1][mask] = 1; pos[1].push_back(mask); } } // for (int i = 2; i <= n; i++) { for (int mask1 : pos[i - 1]) { for (int mask2 = 0; mask2 < full; mask2++) if ((mask1 & mask2) == 0 && s[mask2] == a[i]) { dp[i][mask1 | mask2] = 1; pos[i].push_back(mask1 | mask2); } } } int ans = 0; for (int mask = 0; mask < full; mask++) ans = max(ans, dp[n][mask]); cout << (ans == 0 ? "NO\n" : "YES\n"); return 0; }

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

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