Submission #778020

#TimeUsernameProblemLanguageResultExecution timeMemory
778020vgoofficialBank (IZhO14_bank)C++14
0 / 100
68 ms8504 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n,m; cin >> n >> m; int salary[n], notes[m]; for(int i = 0; i < n; i++) cin >> salary[i]; for(int i = 0; i < m; i++) cin >> notes[i]; int peoplePaid[1<<m]; int lastPerson[1<<m]; peoplePaid[0]=0; lastPerson[0]=0; for(int i = 1; i < 1<<m; i++) { peoplePaid[i]=-1; for(int j = 0; j < m; j++) { if(i&(1<<j)) { if(peoplePaid[i^(1<<j)]==-1) continue; int ppl = peoplePaid[i^(1<<j)]; if(lastPerson[i^(1<<j)]+notes[j]==salary[ppl]) { peoplePaid[i]=ppl+1; lastPerson[i]=0; if(ppl+1==n) { cout << "YES" << endl; exit(0); } } else if(lastPerson[i^(1<<j)]+notes[j]<salary[ppl]) { peoplePaid[i]=ppl; lastPerson[i]=lastPerson[i-1]+notes[j]; } } } } cout << "NO" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...