# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
778024 |
2023-07-10T03:17:41 Z |
vgoofficial |
Bank (IZhO14_bank) |
C++14 |
|
2 ms |
340 KB |
#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 << i << endl;
cout << "YES" << endl;
return 0;
}
} else if(lastPerson[i^(1<<j)]+notes[j]<salary[ppl]) {
peoplePaid[i]=peoplePaid[i^(1<<j)];
lastPerson[i]=lastPerson[i^(1<<j)]+notes[j];
}
}
}
}
cout << "NO" << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |