結果

問題 No.1701 half price
ユーザー NanashimaNanashima
提出日時 2021-10-08 22:23:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 897 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 168,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 10:48:36
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a)  (a).begin(),(a).end()
#define rall(a)  (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;

int main() {
    ll n,w;
    cin >> n >> w;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll cnt=0;
    for(int bit=0;bit<(1<<n);bit++) {
        bool flag=false;
        vector<ll> v;
        ll sum=0;
        rep(i,n) {
            if(1<<i&bit) {
                v.push_back(a[i]);
                sum+=a[i];
            }
        }
        int x=v.size();
        for(int bit2=0;bit2<(1<<x);bit2++) {
            ll tot=sum;
            rep(i,x) if(1<<i&bit2) tot-=v[i]/2;
            if(tot==w) {
                flag=true;
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}
0