Submission #33305
ソースコード
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 32 33 34 35 36 37 38 39 40 41 42 | #include<bits/stdc++.h> using namespace std; bool dfs( int i, int sum); int n,k; int a[26]; int main() { cin>>n>>k; for ( int i=0;i<n;i++){ cin>>a[i]; a[i]= abs (a[i]); } if (dfs(0,0)) cout<< "OK" <<endl; else cout<< "NG" <<endl; return 0; } bool dfs( int i, int sum){ if (sum==k) return true ; if (i==n) return false ; if (dfs(i+1,sum+a[i])) return dfs(i+1,sum+a[i]); return dfs(i+1,sum); } |
ステータス
項目 | データ |
---|---|
問題 | 0491 - 印刷ミス |
ユーザー名 | ei1725 |
投稿日時 | 2018-04-22 21:10:55 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 472 Byte |
最大実行時間 | 22 ms |
最大メモリ使用量 | 480 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input1.txt | AC | 19 ms | 480 KB |
1
|
input2.txt | AC | 19 ms | 456 KB |
1
|
input3.txt | AC | 22 ms | 432 KB |
1
|
input4.txt | AC | 17 ms | 404 KB |
1
|