제출 #991246

#제출 시각아이디문제언어결과실행 시간메모리
991246hippo123은행 (IZhO14_bank)C++17
0 / 100
2 ms1120 KiB
#include <bits/stdc++.h> using namespace std; #define pr pair<int, int> #define ll long long #define pb push_back #define f first #define s second int main(){ int n, m; cin>>n>>m; multiset<int> a; vector<int> b(m); //int amax=0; for (int i=0; i<n; i++) { int temp; cin>>temp; } for (int i=0; i<m; i++) cin>>b[i]; vector<pair<multiset<int>, int>> dp(1<<m, {a, 0}); for (int x=1; x<(1<<m); x++){ pair<multiset<int>, int> mast=dp[x]; multiset<int> nd=mast.f; for (int i=0; i<m; i++){ if(x&(1<<i)){ pair<multiset<int>, int> prev=dp[x^(1<<i)]; multiset<int> elem=prev.f; int last=prev.s; last+=b[i]; if(elem.find(last)!=elem.end()){ elem.erase(last); last=0; } if(nd.size()>elem.size()){ dp[x]={elem, last}; } } } } multiset<int> sf=dp[(1<<m)-1].f; if(sf.size()==0) cout<<"YES"; else cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...