結果

問題 No.1701 half price
ユーザー planesplanes
提出日時 2021-10-09 15:54:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 3,000 ms
コード長 929 bytes
コンパイル時間 1,566 ms
コンパイル使用メモリ 169,248 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 02:05:36
合計ジャッジ時間 2,880 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

int main() {
    ll N,W;cin>>N>>W;
    vector<ll> a(N);
    for(ll i=0;i<N;i++) cin>>a[i];
ll ans=0;

    for(ll i=1;i<(1<<N);i++) {
        bitset<13> S(i);
        vector<ll> vec(0);
        for(ll j=0;j<N;j++) {
            if(S.test(j)) {
            vec.push_back(j);
            }
        }
        ll m=vec.size();
        for(ll tmp=0;tmp<(1<<vec.size());tmp++) {
            bitset<13> s(tmp);
            ll price=0;
            for(ll h=0;h<vec.size();h++) {
                if(s.test(h)) {
                    price+=a[vec[h]]/2;
                }
                else price+=a[vec[h]];
            }

            if(price==W) {
                ans++; break;
            }
        }
    }

    cout<<ans<<endl;
}
                


0