結果

問題 No.1935 Water Simulation
ユーザー SidewaysOwl
提出日時 2022-05-13 22:37:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 60,416 KB
最終ジャッジ日時 2024-07-22 04:36:41
合計ジャッジ時間 2,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,c,d,n = map(int,input().split())
v = [a,b,c,d]
l = [a] + [0] * 3
from collections import defaultdict
dic = defaultdict(int)
dic["-".join(map(str,l+[0]))] = 0
start = 0
loop = 10 ** 18 + 1
for i in range(n):
    ii = (i+1) % 4
    val = min(l[i%4],v[ii]-l[ii])
    l[i%4] -= val
    l[ii] += val
    tps = "-".join(map(str,l+[(i+1)%4]))
    if tps in dic:
        loop = dic[tp]- dic[tps] + 1
        start = dic[tps]
        break
    else:
        dic[tps] = i + 1
    tp = tps
nn = n-start
nn %= loop
end = start + nn
for key in dic.keys():
    if dic[key] == end:
        ans = list(key.split("-"))[:4]
        print(*ans)
        break
0