제출 #977976

#제출 시각아이디문제언어결과실행 시간메모리
977976BentoOreo은행 (IZhO14_bank)C++14
0 / 100
7 ms3676 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<long long, long long>; const ll INF = numeric_limits<ll>::max(); const int inf = numeric_limits<int>::max(); const char nl = '\n', sp = ' '; bool f(int id, int mask, ll val, int N, vector<ll> &salary, vector<ll> &billz, set<pll> &vis,vector<vector<bool> > &dp){ if(vis.count({mask,val})){ return dp[mask][val]; } else { if(id == N){ return true; } else if(val == 0){ return f(id + 1,mask,salary[id + 1], N, salary, billz, vis,dp); } else { vis.insert({mask,val}); int mx = upper_bound(billz.begin(),billz.end(), val) - billz.begin(); bool flag = false; for(int i = 0; i < mx; i++){ if((mask & (1 << i)) != 0){ if(val - billz[i] >= 0){ char retv = f(id, mask ^ (1 << i),val - billz[i],N, salary,billz, vis,dp); flag = true; } } } dp[mask][val] = flag; return dp[mask][val]; } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<vector<bool> > dp((1 << M), vector<bool>(1000,false)); vector<ll> salary; vector<ll> billz; ll num; for(int i = 0; i < N; i++){ cin >> num; salary.push_back(num); } for(int i = 0; i < M; i++){ cin >> num; billz.push_back(num); } sort(billz.begin(),billz.end()); int mask = (1 << M) - 1; set<pll> vis; bool ans = f(0,mask,salary[0], N ,salary, billz, vis,dp); if(ans){ cout << "YES" << nl; } else { cout << "NO" << nl; } }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'bool f(int, int, ll, int, std::vector<long long int>&, std::vector<long long int>&, std::set<std::pair<long long int, long long int> >&, std::vector<std::vector<bool> >&)':
bank.cpp:26:30: warning: unused variable 'retv' [-Wunused-variable]
   26 |                         char retv = f(id, mask ^ (1 << i),val - billz[i],N, salary,billz, vis,dp);
      |                              ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...