結果

問題 No.3642 OHO SHI KA TSU(Buying ver.)
コンテスト
ユーザー shobonvip
提出日時 2026-08-25 15:13:58
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,665 ms / 2,000 ms
+ 803µs
コード長 2,382 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,903 ms
コンパイル使用メモリ 380,020 KB
実行使用メモリ 39,484 KB
最終ジャッジ日時 2026-08-25 15:14:25
合計ジャッジ時間 11,462 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
小課題1 5 % AC * 4
小課題2 3 % AC * 3
小課題3 2 % AC * 3
小課題4 10 % AC * 3
小課題5 15 % AC * 3
小課題6 20 % AC * 3
小課題7 30 % AC * 3
小課題8 15 % AC * 31
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/**
	author:  shobonvip
	created: 2026.08.25 14:58:41
**/

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
#define all(v) v.begin(), v.end()

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;
	int x, y; cin >> x >> y;

	vector<int> wt(n), vt(n), ct(n);
	vector<int> w, v;

	rep(i,0,n) {
		cin >> wt[i] >> vt[i] >> ct[i];

		int g = 1;
		while (g * 2 < ct[i]) {
			g *= 2;
		}
		
		ct[i] -= g;
		if (ct[i] > 0) {
			w.emplace_back(wt[i] * ct[i]);
			v.emplace_back(vt[i] * ct[i]);
		}

		g >>= 1;
		while (g > 0) {
			w.emplace_back(wt[i] * g);
			v.emplace_back(vt[i] * g);
			g >>= 1;
		}

		w.emplace_back(wt[i]);
		v.emplace_back(vt[i]);
	}

	n = w.size();

	ld ub = 100000;
	ld lb = 0;

	

	auto check = [&](ld k) {
		vector dp(n+1, vector<ld>(x, -1e18));

		rep(i,0,n) {
			int opt = w[i] / x;
			chmax(dp[i+1][w[i]%x], v[i] + ld(opt) * y - k * w[i]);

			rep(j,0,x) {
				chmax(dp[i+1][j], dp[i][j]);
				if ((j+w[i]) % x < j) {
					chmax(
						dp[i+1][(j+w[i]) % x],
						dp[i][j] + v[i] + ld(opt+1) * y - k * w[i]
					);
				} else {
					chmax(
						dp[i+1][(j+w[i]) % x],
						dp[i][j] + v[i] + ld(opt) * y - k * w[i]
					);
				}
			}
		}

		return max(dp[n]) >= 0;
	};

	
	rep(num,0,50) {
		ld k = (ub + lb) / 2;
		if (check(k)) lb = k;
		else ub = k;
	} 

	cout << fixed << setprecision(15);
	cout << lb << '\n';
}

0