Submission #22713
ソースコード
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 | #include<bits/stdc++.h> using namespace std; int n,k; int data[26]; int dfs( int i, int ans); int main(){ scanf ( "%d %d" ,&n,&k); for ( int i=0;i<n;i++){ scanf ( "%d" ,&data[i]); } if (dfs(0,0) == 0) cout << "NG" << endl; else cout << "OK" << endl; return 0; } int dfs( int i, int ans){ if (ans == k) return 1; int res=0; if (i != n){ res = dfs(i+1,ans+data[i])+dfs(i+1,ans-data[i]); } return res; } |
ステータス
項目 | データ |
---|---|
問題 | 0491 - 印刷ミス |
ユーザー名 | ei1612 |
投稿日時 | 2017-07-24 04:00:21 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 444 Byte |
最大実行時間 | 49 ms |
最大メモリ使用量 | 528 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input1.txt | AC | 49 ms | 480 KB |
1
|
input2.txt | AC | 45 ms | 452 KB |
1
|
input3.txt | AC | 34 ms | 424 KB |
1
|
input4.txt | AC | 35 ms | 528 KB |
1
|