Submission #28567


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<bits/stdc++.h>
using namespace std;
int dfs(int now,int ans);
int a[25],n,k,i=0;
int main(){
cin>>n>>k;
for(int cnt=0;cnt<n;cnt++){
cin>>a[cnt];
}
int s=dfs(0,0);
if(s>0){
cout<<"OK"<<endl;
}else{
cout<<"NG"<<endl;
}
return 0;
}
int dfs(int now,int ans){
if(k==ans){
return 1;
}else if(now<n){
return dfs(now+1,ans+a[now])+dfs(now+1,ans);
}
return 0;
}

ステータス

項目 データ
問題 0064 - 足し算できる?
ユーザー名 Zzz..ei1704..Zzz
投稿日時 2017-11-13 16:21:49
言語 C++11
状態 Accepted
得点 5
ソースコード長 431 Byte
最大実行時間 32 ms
最大メモリ使用量 612 KB

セット

セット 得点 Cases
1 ALL 5 / 5 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
AddInput1.txt AC 32 ms 480 KB
1
AddInput2.txt AC 21 ms 456 KB
1
AddInput3.txt AC 21 ms 428 KB
1
AddInput4.txt AC 19 ms 532 KB
1
AddInput5.txt AC 25 ms 508 KB
1
AddInput6.txt AC 17 ms 612 KB
1