結果

問題 No.1701 half price
ユーザー asaringoasaringo
提出日時 2021-10-08 22:09:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 636 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 167,156 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 10:25:28
合計ジャッジ時間 2,486 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
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 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)

ll w ;
int n ;

ll A[20] ;

int main(){
    cin >> n >> w ;
    rep(i,n) cin >> A[i] ;
    ll res = 0 ;
    rep(S,1<<n){
        vector<ll> vec ;
        rep(i,n) if(S >> i & 1) vec.push_back(A[i]) ;
        int m = vec.size() ;
        rep(i,m+1){
            ll sum = 0 ;
            rep(j,m){
                if(i == j) sum += vec[j] / 2 ;
                else sum += vec[j] ;
            }
            if(sum == w) res++ ;
        }
    }
    cout << res << endl ;
}
0