Submission #927407

#TimeUsernameProblemLanguageResultExecution timeMemory
927407May27_thBank (IZhO14_bank)C++17
0 / 100
1 ms452 KiB
#include<bits/stdc++.h> #define taskname "A" 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), pref(M + 5, 0), cover((1 << M) + 5, 0); for (int &x : a) cin >> x; for (int &x : b) cin >> x; for (int i = 1; i <= M; i ++) { pref[i] = pref[i - 1] + b[i - 1]; } for (int mask = 1; mask < (1 << M); mask ++) { int tot = 0; for (int i = 0; i < M; i ++) { if (mask >> i & 1) tot = tot + b[i]; } int pos = cover[mask]; if (pos == N - 1) { cout << "YES" << "\n"; return; } if (tot - pref[pos] == b[pos]) { cover[mask] ++; } } 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...