| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 679330 | vjudge1 | 은행 (IZhO14_bank) | C++11 | 142 ms | 1260 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
using namespace std;
int n,m,req[25],has[25];
bool dp[1100005],binrep[25];
int main () {
scanf("%d%d",&n,&m);
for(int i = 0; i < n; i++) {
scanf("%d",&req[i]);
}
for(int i = 0; i < m; i++) {
scanf("%d",&has[i]);
}
dp[0] = true;
for(int i = 0; i < (1<<m)-1; i++) {
if(dp[i] == true) {
for(int j = 0; j < m; j++) {
binrep[j] = false;
}
int cnt = 0, tmp = i;
while(tmp > 0) {
binrep[cnt] = tmp%2;
tmp/=2;
cnt++;
}
int rem = 0;
for(int j = 0; j < m; j++) {
if(binrep[j] == true) rem += has[j];
}
int amn = 0;
while(amn < n && rem-req[amn] >= 0) {
rem-=req[amn];
amn++;
}
if(amn == n && rem == 0) {
printf("YES\n");
return 0;
}
if(amn < n) {
for(int j = 0; j < m; j++) {
if(binrep[j] == false && rem+has[j] <= req[amn]) dp[i+(1<<j)] = true;
}
}
}
}
printf("NO\n");
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... | ||||
