結果

問題 No.1463 Hungry Kanten
ユーザー Manuel1024Manuel1024
提出日時 2021-04-04 18:53:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 77,768 KB
実行使用メモリ 15,708 KB
最終ジャッジ日時 2023-08-27 19:56:01
合計ジャッジ時間 2,512 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 188 ms
15,708 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 15 ms
4,764 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 75 ms
9,612 KB
testcase_20 AC 109 ms
10,820 KB
testcase_21 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
using namespace std;
using ll = long long int;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(auto &p: a) cin >> p;

    set<ll> ans;
    for(int bit = 0; bit < (1 << n); bit++){
        int cnt = 0;
        ll sum = 0;
        ll pro = 1;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                sum += a[i];
                pro *= a[i];
                cnt++;
            }
        }
        if(cnt >= k){
            ans.insert(sum);
            ans.insert(pro);
        }
    }
    //for(auto &p: ans) cerr << p << " ";
    cout << ans.size() << endl;
    return 0;
}
0