結果
| 問題 | 
                            No.1701 half price
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-10-08 22:09:17 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 130 ms / 3,000 ms | 
| コード長 | 732 bytes | 
| コンパイル時間 | 1,979 ms | 
| コンパイル使用メモリ | 171,336 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-23 04:31:36 | 
| 合計ジャッジ時間 | 2,787 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;
typedef long long ll;
int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    int x = 1;
    rep(i, 0, N) x *= 3;
    vector<bool> ok(1 << N, false);
    rep(i, 1, x) {
        ll s = 0, y = i, b = 0;
        rep(j, 0, N) {
            int r = y % 3;
            y /= 3;
            b *= 2;
            if (r == 1) s += a[j] / 2;
            if (r == 2) s += a[j];
            if (r > 0) b++;
        }
        //cout << i << " " << s << endl;
        if (s == W) {
            ok[b] = true;
        }
    }
    int ans = 0;
    rep(i, 0, 1 << N) ans += ok[i];
    cout << ans << endl;
}