Submission #21349
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<bits/stdc++.h> using namespace std; int n,k,a[25]; int f( int idx, int sum); main(){ cin>>n>>k; for ( int i=0;i<n;i++){ cin>>a[i]; } if (f(0,0))cout<< "OK" <<endl; else cout<< "NG" <<endl; } int f( int idx, int sum){ if (sum==k) return 1; if (idx==n) return 0; if (f(idx+1,sum)) return 1; if (f(idx+1,sum+a[idx])) return 1; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | ei1516 |
投稿日時 | 2017-07-11 17:41:39 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 369 Byte |
最大実行時間 | 36 ms |
最大メモリ使用量 | 480 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 11 ms | 480 KB |
1
|
AddInput2.txt | AC | 13 ms | 456 KB |
1
|
AddInput3.txt | AC | 36 ms | 424 KB |
1
|
AddInput4.txt | AC | 14 ms | 400 KB |
1
|
AddInput5.txt | AC | 14 ms | 376 KB |
1
|
AddInput6.txt | AC | 13 ms | 348 KB |
1
|