結果
| 問題 |
No.1701 half price
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-08 22:07:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 732 bytes |
| コンパイル時間 | 1,810 ms |
| コンパイル使用メモリ | 171,628 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 04:26:56 |
| 合計ジャッジ時間 | 3,035 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 WA * 4 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;
typedef long long ll;
int main() {
ll N, W;
cin >> N >> W;
vector<ll> a(N);
rep(i, 0, N) cin >> a[i];
int x = 1;
rep(i, 0, N) x *= 3;
vector<bool> ok(1 << N, false);
rep(i, 0, x) {
ll s = 0, y = i, b = 0;
rep(j, 0, N) {
int r = y % 3;
y /= 3;
b *= 2;
if (r == 1) s += a[j] / 2;
if (r == 2) s += a[j];
if (r > 0) b++;
}
//cout << i << " " << s << endl;
if (s == W) {
ok[b] = true;
}
}
int ans = 0;
rep(i, 0, 1 << N) ans += ok[i];
cout << ans << endl;
}