結果

問題 No.1701 half price
ユーザー Manuel1024Manuel1024
提出日時 2022-12-12 06:58:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 76,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 00:13:07
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 15 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 15 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 145 ms
5,376 KB
testcase_07 AC 141 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 145 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int n, w; cin >> n >> w;
    vector<int> a(n);
    for(auto &it: a) cin >> it;

    set<int> mem;
    int lim = 1;
    for(int i = 0; i < n; i++) lim *= 3;
    for(int bit = 0; bit < lim; bit++){
        ll tot = 0;
        int bit1 = bit;
        int mask = 0;
        for(int i = 0; i < n; i++, bit1 /= 3){
            if(bit1%3 == 0) continue;
            mask |= 1 << i;
            if(bit1%3 == 1) tot += a[i];
            else tot += a[i]/2;
        }
        if(tot == w) mem.emplace(mask);
    }
    cout << mem.size() << endl;
    return 0;
}
0