Submission #32693
ソースコード
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 | #include <bits/stdc++.h> using namespace std; int main(){ int n,k; int a[25]; cin >> n >> k; for ( int i = 0;i < n;i++){ cin >> a[i]; } queue< int > que; que.push(0); int tmp; for ( int i = 0;i < n;i++){ for ( int j = 0 ;j < pow (2,i);j++){ tmp = que.front(); que.pop(); que.push(tmp); que.push(tmp+a[i]); } } que.pop(); int i; for (i = 0;i < pow (2,n)-1;i++){ tmp = que.front(); que.pop(); if (tmp == k){ cout << "OK" << endl; break ; } } if (i == pow (2,n)-1){ cout << "NG" << endl; } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | ei1719 |
投稿日時 | 2018-04-15 23:16:16 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 634 Byte |
最大実行時間 | 147 ms |
最大メモリ使用量 | 4872 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 24 ms | 476 KB |
1
|
AddInput2.txt | AC | 17 ms | 580 KB |
1
|
AddInput3.txt | AC | 23 ms | 552 KB |
1
|
AddInput4.txt | AC | 147 ms | 4872 KB |
1
|
AddInput5.txt | AC | 38 ms | 1680 KB |
1
|
AddInput6.txt | AC | 20 ms | 572 KB |
1
|