結果

問題 No.1935 Water Simulation
ユーザー ikomaikoma
提出日時 2022-05-13 22:26:55
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 383 ms
使用メモリ 79,520 KB
最終ジャッジ日時 2023-02-21 18:39:09
合計ジャッジ時間 4,598 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 89 ms
79,520 KB
testcase_01 AC 92 ms
79,448 KB
testcase_02 AC 87 ms
75,548 KB
testcase_03 AC 85 ms
75,736 KB
testcase_04 AC 87 ms
75,628 KB
testcase_05 AC 88 ms
75,720 KB
testcase_06 AC 87 ms
75,408 KB
testcase_07 AC 86 ms
75,732 KB
testcase_08 AC 86 ms
75,896 KB
testcase_09 AC 85 ms
75,696 KB
testcase_10 AC 86 ms
75,424 KB
testcase_11 AC 88 ms
75,488 KB
testcase_12 AC 85 ms
75,792 KB
testcase_13 AC 90 ms
75,544 KB
testcase_14 AC 86 ms
75,420 KB
testcase_15 AC 87 ms
75,416 KB
testcase_16 AC 88 ms
75,736 KB
testcase_17 AC 88 ms
75,424 KB
testcase_18 AC 86 ms
75,500 KB
testcase_19 AC 89 ms
75,736 KB
testcase_20 AC 89 ms
75,748 KB
testcase_21 AC 87 ms
75,424 KB
testcase_22 AC 87 ms
75,520 KB
testcase_23 AC 89 ms
75,372 KB
testcase_24 AC 88 ms
75,708 KB
testcase_25 AC 88 ms
75,512 KB
testcase_26 AC 88 ms
75,480 KB
testcase_27 AC 88 ms
75,628 KB
testcase_28 AC 87 ms
75,492 KB
testcase_29 AC 86 ms
75,720 KB
testcase_30 AC 85 ms
75,692 KB
testcase_31 AC 87 ms
75,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

V1,V2,V3,V4,N=map(int,input().split())
def solve(V1,V2,V3,V4,N):
    V=(V1,V2,V3,V4)
    s=[V1,0,0,0]
    st = {tuple(s):0}
    ts = [tuple(s)]
    i=0
    cnt=0
    while N>0:
        N-=1
        cnt+=1
        v=s[i]
        ib=i
        i+=1
        if i>3:i=0
        nxt=s[i]
        c=V[i]
        d=min(c-nxt,v)
        s[i]+=d
        s[ib]-=d
        t = tuple(s+[i])
        if t in st:
            l=st[t]
            loop=cnt-l
            N%=loop
            s = ts[l+N]
            break
        st[t]=cnt
        ts.append(t[:4])
    return s

print(*solve(V1,V2,V3,V4,N))
0