結果

問題 No.2158 X日後に全完するhibit君
ユーザー 沙耶花沙耶花
提出日時 2022-12-09 21:54:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 4,511 ms
コンパイル使用メモリ 260,288 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-04 23:30:00
合計ジャッジ時間 6,208 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 9 ms
4,384 KB
testcase_03 AC 40 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 15 ms
4,384 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 7 ms
4,384 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 214 ms
4,380 KB
testcase_24 AC 7 ms
4,380 KB
testcase_25 AC 7 ms
4,388 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 212 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 2000000000000000001



int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<int> p(N),s(N),t(N);
	rep(i,N){
		cin>>p[i]>>s[i]>>t[i];
	}
	int mm = 1;
	rep(i,N)mm *= 6;
	vector<double> dp(mm,0.0);
	dp[0] = 1.0;
	int x = Inf32,y = -Inf32;
	double z = 0.0;
	
	rep(i,50){
		vector<double> ndp(mm,0.0);
		rep(j,mm){
			if(dp[j]==0.0)continue;
			int tt = min(i,K);
			vector<int> nums(N);
			{
				int cc = j;
				rep(k,N){
					nums[k] = cc%6;
					cc /= 6;
				}
			}
			rep(k,1<<N){
				int sum = 0;
				double pp = 1.0;
				int to = 0;
				int cv = 1;
				rep(l,N){
					if((k>>l)&1){
						sum += t[l];
						pp *= ((double)nums[l]-tt)/(p[l]-tt);
						to += cv * nums[l];
					}
					else{
						sum += s[l];
						pp *= ((double)p[l]-nums[l])/(p[l]-tt);
						to += cv * (nums[l]+1);
					}
					cv *= 6;
				}
				if(pp==0.0)continue;
				if(sum <= 60){
					x = min(x,i+1);
					y = max(y,i+1);
					z += dp[j]*pp*(i+1);
					continue;
				}
				ndp[to] += dp[j] * pp;
				
			}
		}
		swap(dp,ndp);
	}
	
	if(x==Inf32){
		cout<<-1<<endl;
		return 0;
	}
	
	cout<<x<<' '<<y<<' ';
	cout<<fixed<<setprecision(11)<<z<<endl;
	
	return 0;
}
0