Submission #998091

#TimeUsernameProblemLanguageResultExecution timeMemory
998091HUYHDUVE은행 (IZhO14_bank)C++14
0 / 100
162 ms24156 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll const INF = 1e8; struct state{ int id = INF, left = INF, cnt = INF; bool operator < (const state &other){ if(id == other.id){ if(cnt == other.cnt) { return left < other.left; } return cnt < other.cnt; } return id < other.id; } }; int main(){ freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int n, m; cin >> n >> m; vector<int> peo(n), cash(m); for(auto &it : peo) cin >> it; for(auto &it : cash) cin >> it; sort(peo.rbegin(), peo.rend()); sort(cash.rbegin(), cash.rend()); vector<state> take(1 << m); take[0].id = 0; take[0].left = peo[0]; take[0].cnt = 0; for(int mask = 0; mask < (1 << m); mask++){ for(int j = 0; j < m; j++){ if(mask & (1 << j)) continue; state z = take[mask]; if(cash[j] <= z.left){ z.left -= cash[j]; z.cnt ++; } if(z.left == 0){ z.id ++; z.left = (z.id < n ? peo[z.id] : 0); } if(z < take[mask | (1 << j)]){ take[mask | (1 << j)] = z; } } } bool f = 0; for(int mask = 0; mask < (1 << m); mask ++){ if(take[mask].id == n && take[mask].left == 0){ f = 1; } } if(f) cout << "YES"; else cout << "NO"; }

Compilation message (stderr)

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