| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 778025 | vgoofficial | 은행 (IZhO14_bank) | C++14 | 106 ms | 8520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
