Submission #648174

#TimeUsernameProblemLanguageResultExecution timeMemory
648174TS_2392Bank (IZhO14_bank)C++14
0 / 100
2 ms388 KiB
#include <bits/stdc++.h> #define FAST ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0) #define rall(x) (x).rbegin(), (x).rend() #define all(x) (x).begin(), (x).end() #define sqr(x) (x) * (x) #define epb emplace_back #define lwb lower_bound #define upb upper_bound #define mp make_pair #define fi first #define se second using namespace std; typedef long long ll; typedef long double ldb; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; typedef pair<int, ll> pil; typedef pair<int, int> pii; typedef pair<ldb, ldb> pld; typedef pair<double, double> pdd; const int oo = 1e4; int n, m, a[21], b[21]; pii dp[1 << 20]; int main(){ FAST; freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> a[i]; for(int i = 0; i < m; ++i) cin >> b[i]; dp[0] = mp(1, 0); for(int mask = 1; mask < 1 << m; ++mask){ dp[mask].se = oo; for(int i = 0; i < m; ++i) if(mask >> i & 1){ int x = mask ^ 1 << i, idx = dp[x].fi; if(dp[x].se >= oo) continue; if(dp[x].se + b[i] > a[idx]) break; dp[mask].fi = dp[x].fi; dp[mask].se = dp[x].se + b[i]; if(dp[mask].se == a[idx]){ dp[mask].fi++; dp[mask].se = 0; } break; } if(dp[mask].fi == n + 1 && dp[mask].se == 0){ cout << "YES"; exit(0); } } cout << "NO"; return 0; }

Compilation message (stderr)

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