結果

問題 No.1701 half price
ユーザー Taichi Fujii
提出日時 2021-10-08 22:50:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 775 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 71,264 KB
最終ジャッジ日時 2025-01-24 23:04:29
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main(void){
    ll N, W;
    cin >> N >> W;

    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    ll ans = 0;
        
    for(int p = 0; p < (1 << N); p++){
        for(int p2 = 0; p2 < (1 << N); p2++){
            ll s = 0;
            for(int i = 0; i < N; i++){
                int idx = (p >> i) & 1;
                int idx2 = (p2 >> i) & 1;
                
                if (idx & idx2){
                    s += A[i] / 2;
                }else if (idx){
                    s += A[i];
                }
            }
            if (s == W){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}
0