Submission #07877
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<bits/stdc++.h> using namespace std; int sum( int x, int total); int n,k,s[30]; main(){ cin>>n>>k; for ( int i=0;i<n;i++){ cin>>s[i]; } if (sum(0,0)==1){ cout<< "OK" <<endl; } else { cout<< "NG" <<endl; } } int sum( int x, int total){ if (total>k || x>n) return 0; if (total==k) return 1; return (sum(x+1,total+s[x])||sum(x+1,total)); } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | ei1541 |
投稿日時 | 2016-07-29 10:08:16 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 384 Byte |
最大実行時間 | 53 ms |
最大メモリ使用量 | 708 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 53 ms | 476 KB |
1
|
AddInput2.txt | AC | 16 ms | 708 KB |
1
|
AddInput3.txt | AC | 17 ms | 560 KB |
1
|
AddInput4.txt | AC | 22 ms | 664 KB |
1
|
AddInput5.txt | AC | 14 ms | 520 KB |
1
|
AddInput6.txt | AC | 19 ms | 496 KB |
1
|