結果

問題 No.1701 half price
ユーザー yakkiyakki
提出日時 2021-10-08 22:05:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 200,064 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-30 10:17:08
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,380 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 2 ms
4,376 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;
        rep(j,n) if(i>>j&1) tmp += a[j];
        if(tmp == w) ans++;
        rep(j,n){
            if(i>>j&1){
                if(tmp-a[j]+b[j] == w) ans++;
            }
        }
    }
    cout << ans << endl;

}


0