結果

問題 No.1701 half price
ユーザー batsumarubatsumaru
提出日時 2021-10-08 22:19:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 916 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 166,720 KB
実行使用メモリ 7,880 KB
最終ジャッジ日時 2023-09-30 10:43:23
合計ジャッジ時間 6,518 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, w;
  cin >> n >> w;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  ll N = 1LL << n;
  ll ans = 0;
  FOR(c, 1, N) {
    bool ok = false;
    REP(b, N) {
      ll cnt = 0;
      REP(i, n) {
        bool isHalf = (b & (1LL << i)) > 0;
        bool select = (c & (1LL << i)) > 0;
        ll price = isHalf ? a[i] / 2 : a[i];
        if (select) {
          cnt += price;
        }
      }
      if (cnt == w) {
        ok = true;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
0