Submission #927420

#TimeUsernameProblemLanguageResultExecution timeMemory
927420May27_thBank (IZhO14_bank)C++17
100 / 100
101 ms8788 KiB
#include<bits/stdc++.h> #define taskname "bank" using namespace std; void World_Final(); void Solve(); int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } World_Final(); } void World_Final(){ int Tests = 1; //cin >> Tests; while (Tests --) { Solve(); } } void Solve(){ int N, M; cin >> N >> M; vector<int> a(N), b(M), leftover((1 << M) + 5, -1), cover((1 << M) + 5, -1); for (int &x : a) cin >> x; for (int &x : b) cin >> x; cover[0] = leftover[0] = 0; for (int mask = 1; mask < (1 << M); mask ++) { for (int i = 0; i < M; i ++) { if (mask >> i & 1) { int prev = mask ^ (1 << i); if (cover[prev] != -1 && leftover[prev] != -1) { int current_money = leftover[prev] + b[i]; int target = a[cover[prev]]; if (current_money < target) { cover[mask] = cover[prev]; leftover[mask] = current_money; } else if (current_money == target) { cover[mask] = cover[prev] + 1; leftover[mask] = 0; } } } } if (cover[mask] == N) { cout << "YES" << "\n"; return; } } cout << "NO" << "\n"; } /** **/

Compilation message (stderr)

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