結果

問題 No.2158 X日後に全完するhibit君
ユーザー kotatsugamekotatsugame
提出日時 2022-12-09 21:49:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,218 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 92,976 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-04 23:18:43
合計ジャッジ時間 3,015 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<iomanip>
using namespace std;
int N,K;
int P[6],s[6],t[6];
map<vector<int>,tuple<int,int,double> >memo;
tuple<int,int,double>f(vector<int>A)
{
	if(memo.find(A)!=memo.end())return memo[A];
	int mn=1e9,mx=-1;
	double p=0;
	int a[6],b[6];
	int W=1;
	for(int i=0;i<N;i++)
	{
		int k=min(K,A[i]);
		a[i]=A[i]-k,b[i]=P[i]-A[i];
		W*=a[i]+b[i];
	}
	for(int i=0;i<1<<N;i++)
	{
		int w=1,sum=0;
		vector<int>B=A;
		for(int j=0;j<N;j++)
		{
			if(i>>j&1)
			{
				w*=a[j];
				sum+=t[j];
			}
			else
			{
				w*=b[j];
				B[j]++;
				sum+=s[j];
			}
		}
		if(w==0)continue;
		tuple<int,int,double>now;
		if(sum<=60)now=make_tuple(1,1,(double)w/W);
		else
		{
			now=f(B);
			get<0>(now)++;
			get<1>(now)++;
			get<2>(now)=(get<2>(now)+1)*(double)w/W;
		}
		mn=min(mn,get<0>(now));
		mx=max(mx,get<1>(now));
		p+=get<2>(now);
	}
	return memo[A]=make_tuple(mn,mx,p);
}
int main()
{
	cin>>N>>K;
	int st=0;
	for(int i=0;i<N;i++)
	{
		cin>>P[i]>>s[i]>>t[i];
		st+=t[i];
	}
	if(st>60)
	{
		cout<<-1<<endl;
		return 0;
	}
	tuple<int,int,double>ret=f(vector<int>(N,0));
	cout<<get<0>(ret)<<" "<<get<1>(ret)<<" "<<fixed<<setprecision(16)<<get<2>(ret)<<endl;
}
0