結果
| 問題 |
No.1701 half price
|
| コンテスト | |
| ユーザー |
batsumaru
|
| 提出日時 | 2021-10-08 22:19:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 916 bytes |
| コンパイル時間 | 1,665 ms |
| コンパイル使用メモリ | 170,208 KB |
| 実行使用メモリ | 13,756 KB |
| 最終ジャッジ日時 | 2024-07-23 04:50:19 |
| 合計ジャッジ時間 | 6,531 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 TLE * 3 |
ソースコード
#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;
}
batsumaru