結果

問題 No.1701 half price
ユーザー Preds1dentPreds1dent
提出日時 2021-10-08 22:19:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,188 bytes
コンパイル時間 4,174 ms
コンパイル使用メモリ 265,460 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-30 10:42:52
合計ジャッジ時間 14,064 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#ifdef _DEBUG
#define xD cerr
#define xO <<
#define xx(x1) x1
#define xP endl
#else
#define xD
#define xO
#define xx(x1)
#define xP
#endif
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
using i64 = long long;
using uni64 = unsigned long long;
using i_i = pair<int, int>;
using i_b = pair<int, bool>;
using l_l = pair<i64, i64>;
using d_d = pair<double, double>;
constexpr int INF = 2147483647;
constexpr i64 I64F = 9223372036854775807;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n, w; cin >> n >> w;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b(n);
	set<int> cnt;
	for (int bit = 0; bit < (1<<n); bit++) {
		b = a;
		for (int i = 0; i < n; i++) {
			if (bit & (1<<i)) {
				b[i] /= 2;
			}
		}
		for (int bit2 = 0; bit2 < (1<<n); bit2++) {
			int sum = 0;
			for (int i = 0; i < n; i++) {
				if (bit2 & (1<<i)) {
					sum += b[i];
				}
				if (sum > w) break;
			}
			if (sum == w) cnt.insert(bit2);
		}
	}
	cout << cnt.size() << endl;
	return 0;
}
0