結果

問題 No.1935 Water Simulation
ユーザー shobonvipshobonvip
提出日時 2022-05-13 21:35:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 734 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,612 KB
実行使用メモリ 71,424 KB
最終ジャッジ日時 2023-09-29 06:36:27
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 86 ms
71,228 KB
testcase_05 AC 87 ms
71,404 KB
testcase_06 AC 86 ms
71,076 KB
testcase_07 AC 86 ms
71,184 KB
testcase_08 AC 85 ms
71,424 KB
testcase_09 AC 86 ms
71,144 KB
testcase_10 AC 87 ms
71,020 KB
testcase_11 AC 91 ms
71,020 KB
testcase_12 AC 91 ms
71,268 KB
testcase_13 AC 90 ms
71,260 KB
testcase_14 AC 88 ms
71,220 KB
testcase_15 AC 89 ms
71,192 KB
testcase_16 AC 88 ms
71,148 KB
testcase_17 AC 88 ms
71,284 KB
testcase_18 AC 88 ms
71,144 KB
testcase_19 AC 89 ms
71,424 KB
testcase_20 AC 89 ms
71,408 KB
testcase_21 AC 87 ms
71,144 KB
testcase_22 AC 87 ms
71,308 KB
testcase_23 AC 85 ms
71,272 KB
testcase_24 AC 86 ms
71,076 KB
testcase_25 AC 87 ms
71,284 KB
testcase_26 AC 89 ms
71,288 KB
testcase_27 AC 88 ms
71,124 KB
testcase_28 AC 93 ms
71,240 KB
testcase_29 AC 89 ms
71,072 KB
testcase_30 AC 87 ms
71,092 KB
testcase_31 AC 86 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

a,b,c,d,n = map(int,input().split())
v = [a,0,0,0]
pro = defaultdict(lambda:-1)
loop = []


tmp = " ".join([str(v[i]) for i in range(4)])
loop.append(tmp)
pro[tmp] = 0

i = 0
while True:
	if i % 4 == 0:
		targ = min(v[0], b-v[1])
		v[0] -= targ
		v[1] += targ
	elif i % 4  == 1:
		targ = min(v[1], c-v[2])
		v[1] -= targ
		v[2] += targ
	elif i % 4 == 2:
		targ = min(v[2], d-v[3])
		v[2] -= targ
		v[3] += targ
	else:
		targ = min(v[3], a-v[0])
		v[3] -= targ
		v[0] += targ
	tmp = " ".join([str(v[i]) for i in range(4)])
	if pro[tmp] >= 0:
		rep = i+1 - pro[tmp]
		ind = pro[tmp]
		break
	pro[tmp] = i+1
	loop.append(tmp)
	i += 1

if n < ind:
	print(loop[n])
else:
	print(loop[ind + (n-ind)%rep])
0