結果

問題 No.1701 half price
ユーザー Manuel1024
提出日時 2022-12-12 06:58:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 76,892 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 06:42:40
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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