結果

問題 No.2158 X日後に全完するhibit君
ユーザー shobonvipshobonvip
提出日時 2022-12-09 23:00:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,271 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-04-22 22:54:51
合計ジャッジ時間 2,915 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,760 KB
testcase_01 AC 45 ms
53,504 KB
testcase_02 AC 117 ms
76,928 KB
testcase_03 AC 46 ms
53,504 KB
testcase_04 AC 46 ms
53,760 KB
testcase_05 AC 47 ms
53,760 KB
testcase_06 AC 67 ms
67,072 KB
testcase_07 AC 45 ms
53,632 KB
testcase_08 AC 77 ms
70,656 KB
testcase_09 AC 46 ms
53,504 KB
testcase_10 AC 46 ms
53,760 KB
testcase_11 AC 46 ms
53,888 KB
testcase_12 AC 45 ms
53,632 KB
testcase_13 AC 45 ms
54,400 KB
testcase_14 AC 65 ms
65,792 KB
testcase_15 AC 47 ms
54,272 KB
testcase_16 AC 46 ms
54,016 KB
testcase_17 AC 45 ms
53,952 KB
testcase_18 AC 47 ms
53,760 KB
testcase_19 AC 54 ms
61,440 KB
testcase_20 AC 47 ms
54,016 KB
testcase_21 AC 46 ms
53,760 KB
testcase_22 AC 46 ms
54,144 KB
testcase_23 AC 46 ms
54,016 KB
testcase_24 AC 46 ms
54,016 KB
testcase_25 AC 45 ms
54,016 KB
testcase_26 AC 89 ms
74,368 KB
testcase_27 AC 47 ms
53,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,k = map(int,input().split())
p = [0] * n
s = [0] * n
t = [0] * n
for i in range(n):
	p[i], s[i], t[i] = map(int,input().split())

if sum(t) > 60:
	print(-1)
	exit()

g = defaultdict(lambda:-1)
minans = 9999999999999
maxans = 0

def dfs(date, used, unused):
	global minans, maxans, k
	targ = (date << 50) + (used << 25) + unused
	if g[targ] >= 0:
		return g[targ]
	l = 1
	ul = [0] * n
	unl = [0] * n
	if date >= k+2:
		for i in range(n):
			used += 6 ** i
	rrr = 1
	for i in range(n):
		ul[i] += (used // rrr) % 6
		unl[i] += (unused // rrr) % 6
		rrr *= 6
	#print(ul, unl)
	ret = 0
	for i in range(1 << n):
		l = 1
		nused = used
		nunused = unused
		mode = 1
		T = 0
		for j in range(n):
			if i >> j & 1:
				if ul[j] == 0:
					mode = 0
					break
				l *= ul[j] / (ul[j] + unl[j])
				T += t[j]
				nused -= 6 ** j
			else:
				if unl[j] == 0:
					mode = 0
					break
				l *= unl[j] / (ul[j] + unl[j])
				T += s[j]
				nunused -= 6 ** j
		if mode:
			if T <= 60:
				ret += l * date
				minans = min(date, minans)
				maxans = max(date, maxans)
			else:
				ret += l * dfs(date + 1, nused, nunused)
	g[targ] = ret
	return ret

start = 0
for i in range(n):
	start += p[i] * 6 ** i

r = dfs(1, 0, start)
print(minans, maxans, r)
0