Submission #895739

#TimeUsernameProblemLanguageResultExecution timeMemory
895739KodikBank (IZhO14_bank)C++17
0 / 100
111 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define ff first #define ss second int main(){ ios_base::sync_with_stdio(false), cin.tie(NULL); freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int p, m; cin >> p >> m; vector<int> people(p); vector<int> money(m); for(int &i : people) {cin >> i;} for(int &i : money) {cin >> i;} vector<int> leftover(1<<m, -1); vector<int> people_covered(1<<m, -1); leftover[0] = 0; people_covered[0] = 0; for(int s = 0; s < (1<<m); ++s){ for(int last = 0; last < m; ++last){ if(!(s&(1<<last))) continue; int prev = s & ~(1<<last); if(people_covered[prev]==-1) continue; int new_amt = leftover[prev] + money[last]; int curr_target = people[people_covered[prev]]; if(new_amt < curr_target){ people_covered[s] = people_covered[prev]; leftover[s] = new_amt; }else if(new_amt==curr_target){ people_covered[s] = people_covered[prev]+1; leftover[s] = 0; } } if(people_covered[s]==p){ cout << "YES\n"; return 0; } } cout << "NO\n"; return 0; }

Compilation message (stderr)

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