結果

問題 No.1701 half price
ユーザー yakkiyakki
提出日時 2021-10-08 22:13:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 3,000 ms
コード長 1,137 bytes
コンパイル時間 3,450 ms
コンパイル使用メモリ 203,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 10:32:04
合計ジャッジ時間 3,253 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,0,1,0};
int dw[] = {0,1,0,-1};


int main(){
    int n; cin >> n;
    ll w; cin >> w;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> b(n);
    rep(i,n) b[i] = a[i]/2;

    ll ans = 0;
    repr(i,1,1<<n){
        ll tmp = 0;
        vector<int> id;
        rep(j,n){
            if(i>>j&1){
                tmp += a[j];
                id.push_back(j);
            }
        }
        bool ok = false;

        int k = id.size();
        rep(j,1<<k){
            ll tmp2 = tmp;
            rep(l,k) if(j>>l&1) tmp2 = tmp2-a[id[l]]+b[id[l]];
            if(tmp2 == w) ok = true;
        }

        if(ok) ans++;
    }
    cout << ans << endl;

}


0