Submission #71159
ソースコード
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 main(){ int N,K; cin>>N>>K; int a[N]; for ( int i=0;i<N;i++){ cin>>a[i]; } int sum; for ( int bit=0;bit<(1<<N);bit++){ sum=0; for ( int i=0;i<N;i++){ if (bit&(1<<i)){ sum+=a[i]; } } if (sum==K){ cout<< "OK" << "\n" ; return (0); } } cout<< "NG" << "\n" ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | ei2122 |
投稿日時 | 2022-07-14 17:29:33 |
言語 | C++17 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 479 Byte |
最大実行時間 | 68 ms |
最大メモリ使用量 | 700 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 38 ms | 604 KB |
1
|
AddInput2.txt | AC | 20 ms | 700 KB |
1
|
AddInput3.txt | AC | 45 ms | 668 KB |
1
|
AddInput4.txt | AC | 68 ms | 640 KB |
1
|
AddInput5.txt | AC | 20 ms | 612 KB |
1
|
AddInput6.txt | AC | 19 ms | 456 KB |
1
|