#include <stdio.h>
 
int sol(int,int);
 
int A[2001],m[2001];
 
int n;
 
int main(){
  int i,j,q;
 
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &m[i]);
  }
 
  for(i=0;i<q;i++){
    if(sol(0,m[i]))printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}
 
int sol(int x, int y){
 
  if(A[x] == y)return 1;
 
  if(x+1  == n)return 0;
 
  if(sol(x+1,y-A[x]) || sol(x+1,y))return 1;
  return 0;
 }
Compile Error Logs:
You are not authorized to see the message.

ステータス
Judge: 10/10 	C 	CPU: 00.30 sec 	Memory: 584 KB 	Length: 472 B 	2015-05-15 09:49 	2015-05-15 09:49
テストケースの判定結果
Case # 	Verdict 	CPU Time 	Memory 	In 	Out 	Case Name
Case #1: 	: Accepted 	00.00 sec 	584 KB 	45 B 	36 B 	test_case_1
Case #2: 	: Accepted 	00.00 sec 	584 KB 	68 B 	73 B 	test_case_2
Case #3: 	: Accepted 	00.00 sec 	584 KB 	356 B 	374 B 	test_case_3
Case #4: 	: Accepted 	00.00 sec 	584 KB 	319 B 	398 B 	test_case_4
Case #5: 	: Accepted 	00.00 sec 	584 KB 	342 B 	399 B 	test_case_5
Case #6: 	: Accepted 	00.00 sec 	584 KB 	321 B 	343 B 	test_case_6
Case #7: 	: Accepted 	00.00 sec 	584 KB 	402 B 	375 B 	test_case_7
Case #8: 	: Accepted 	00.00 sec 	584 KB 	435 B 	322 B 	test_case_8
Case #9: 	: Accepted 	00.04 sec 	584 KB 	493 B 	336 B 	test_case_9
Case #10: 	: Accepted 	00.30 sec 	584 KB 	950 B 	680 B 	test_case_10
< prev | 	1 	/ 	10 	| next > 	  		 : Accepted        00.00 sec        584 KB
 
Judge Input #1 ( in1.txt | 45 B) 		Judge Output #1 ( out1.txt | 36 B)

5
1 5 7 10 21
10
2 4 6 15 17 8 22 21 100 35 

		

no
no
yes
yes
yes
yes
yes
yes
no
no

Comments
 
 工事中です。
 
Categories
 
 
Free Tags
 
 