| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 870841 | ljlkj | Bank (IZhO14_bank) | C++14 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main(){
int n , m;
cin >> n >> m;
vector<int> persons(n);
vector<int> notes(m);
for(int i = 0; i < n; i++) cin >> persons[i];
for(int i = 0; i < m; i++) cin >> notes[i];
vector<pair<int , int>> dp(1<<m);
for(int s = 0; s < (1<<m); s++){
dp[s].first = -1;
dp[s].second = 0;
for(int b = 0; b < n; b++){
if(s&&(1<<b)){
int lastIndex = dp[s^(1<<b)].first;
int value = dp[s^(1<<b)].second;
if(notes[b] + value == persons[lastIndex]){
if(dp[s].first < lastIndex + 1){
dp[s].first = lastIndex + 1;
dp[s].second = 0;
}
}
else if(notes[b] + value < persons[lastIndex]){
if(dp[s].first < lastIndex){
dp[s].first = lastIndex;
dp[s].second = value + notes[b];
}
}
}
}
}
// cout << "test: " << dp[(1<<m) - 1].first << endl;
if(dp[(1<<m) - 1].first == n) cout << "YES";
else cout << "NO";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
