結果

問題 No.1701 half price
ユーザー planesplanes
提出日時 2021-10-09 15:51:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 169,548 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 02:00:24
合計ジャッジ時間 3,691 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 WA -
testcase_02 AC 8 ms
4,372 KB
testcase_03 WA -
testcase_04 AC 8 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 85 ms
4,372 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,372 KB
testcase_10 AC 1 ms
4,372 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,368 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 85 ms
4,372 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=0;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++;
        }
    }
    cout<<ans<<endl;
}
                
0