Submission #14375
ソースコード
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 26 27 28 29 30 31 | #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int n,k; int a[30]; int slv( int now, int t){ if (now==n){ if (t==k) return 1; else return 0; } return (slv(now+1,t+a[now]) | slv(now+1,t)); } int main(){ scanf ( " %d %d" ,&n,&k); for ( int i=0;i<n;i++){ scanf ( " %d" ,&a[i]); } if (slv(0,0)){ printf ( "OK\n" ); } else { printf ( "NG\n" ); } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | Xyca. |
投稿日時 | 2017-04-18 17:08:22 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 444 Byte |
最大実行時間 | 29 ms |
最大メモリ使用量 | 716 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 22 ms | 480 KB |
1
|
AddInput2.txt | AC | 29 ms | 716 KB |
1
|
AddInput3.txt | AC | 17 ms | 576 KB |
1
|
AddInput4.txt | AC | 24 ms | 432 KB |
1
|
AddInput5.txt | AC | 13 ms | 540 KB |
1
|
AddInput6.txt | AC | 17 ms | 524 KB |
1
|