# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
392618 | vanic | 은행 (IZhO14_bank) | C++14 | 1083 ms | 276 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;
const int maxn=20;
int n, m;
int a[maxn];
int b[maxn];
bitset < maxn > p;
bool rek(int x, int y, int br){
if(x==n){
return 1;
}
if(br==a[x]){
return rek(x+1, 0, 0);
}
if(y==m || br>a[x]){
return 0;
}
if(p[y]){
return rek(x, y+1, br);
}
br+=b[y];
p[y]=1;
if(rek(x, y+1, br)){
return 1;
}
br-=b[y];
p[y]=0;
if(rek(x, y+1, br)){
return 1;
}
return 0;
}
bool cmp(int a, int b){
return a>b;
}
int main(){
scanf("%d%d", &n, &m);
for(int i=0; i<n; i++){
scanf("%d", a+i);
}
sort(a, a+n, cmp);
for(int i=0; i<m; i++){
scanf("%d", b+i);
}
sort(b, b+m);
if(rek(0, 0, 0)){
printf("YES\n");
}
else{
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... |