# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
8105 | baneling100 | Bank (IZhO14_bank) | C++98 | 1074 ms | 604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <stdlib.h>
int N, M, A[21], B[21];
void input(void) {
int i;
scanf("%d %d",&N,&M);
for(i=1 ; i<=N ; i++)
scanf("%d",&A[i]);
for(i=1 ; i<=M ; i++)
scanf("%d",&B[i]);
}
void BitMask(int Lev, int Sum, int Bit, int S) {
if(Lev>N) {
printf("YES");
exit(0);
}
else {
if(Sum)
for(int i=S ; i<M ; i++) {
if(!(Bit&(1<<i)) && Sum>=B[i+1])
BitMask(Lev,Sum-B[i+1],Bit|(1<<i),i+1);
}
else
BitMask(Lev+1,A[Lev+1],Bit,0);
}
}
int main(void) {
input();
BitMask(1,A[1],0,0);
printf("NO");
return 0;
}
Compilation message (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... |