Submission #871944

#TimeUsernameProblemLanguageResultExecution timeMemory
871944chuongdanBank (IZhO14_bank)C++14
0 / 100
1 ms348 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 = "bt"; 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]; struct info{ int val = 0, left = 0; bool operator < (info y){ if (val == y.val) return left < y.left; return val < y.val; } } dp[(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){ info k = dp[mask ^ (1<<(i-1))]; if (k.left + b[i] == a[k.val + 1]){ k.val ++; k.left = 0; } else { k.left += b[i]; } if (dp[mask] < k) dp[mask] = k; } } } if (dp[(1<<m) - 1].val == n) 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(); }

Compilation message (stderr)

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