Submission #34576
ソースコード
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 | #include <bits/stdc++.h> using namespace std; int N,K; int a[25]; bool isSum = false ; void dfs( int i, int n){ if (i == N){ if (n == K){ isSum = true ; } return ; } dfs(i+1,n); dfs(i+1,n-a[i]); } int main(){ cin >> N >> K; for ( int i = 0;i < N;i++) cin >> a[i]; dfs(0,0); if (isSum){ cout << "OK" << endl; } else { cout << "NG" << endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0491 - 印刷ミス |
ユーザー名 | ei1719 |
投稿日時 | 2018-05-03 00:29:10 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 408 Byte |
最大実行時間 | 69 ms |
最大メモリ使用量 | 664 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input1.txt | AC | 69 ms | 480 KB |
1
|
input2.txt | AC | 16 ms | 460 KB |
1
|
input3.txt | AC | 25 ms | 560 KB |
1
|
input4.txt | AC | 21 ms | 664 KB |
1
|