結果

問題 No.1935 Water Simulation
ユーザー ikomaikoma
提出日時 2022-05-13 22:26:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 75,076 KB
最終ジャッジ日時 2023-09-29 09:54:46
合計ジャッジ時間 4,173 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
74,788 KB
testcase_01 AC 73 ms
75,076 KB
testcase_02 AC 69 ms
71,440 KB
testcase_03 AC 69 ms
71,140 KB
testcase_04 AC 69 ms
71,180 KB
testcase_05 AC 69 ms
71,140 KB
testcase_06 AC 68 ms
71,324 KB
testcase_07 AC 68 ms
71,324 KB
testcase_08 AC 71 ms
71,136 KB
testcase_09 AC 70 ms
71,100 KB
testcase_10 AC 69 ms
71,300 KB
testcase_11 AC 73 ms
71,268 KB
testcase_12 AC 71 ms
71,140 KB
testcase_13 AC 69 ms
71,244 KB
testcase_14 AC 71 ms
71,504 KB
testcase_15 AC 70 ms
71,320 KB
testcase_16 AC 69 ms
71,360 KB
testcase_17 AC 68 ms
71,448 KB
testcase_18 AC 69 ms
71,276 KB
testcase_19 AC 72 ms
71,112 KB
testcase_20 AC 71 ms
71,488 KB
testcase_21 AC 69 ms
71,112 KB
testcase_22 AC 71 ms
71,228 KB
testcase_23 AC 68 ms
71,488 KB
testcase_24 AC 71 ms
71,140 KB
testcase_25 AC 70 ms
71,468 KB
testcase_26 AC 67 ms
71,320 KB
testcase_27 AC 69 ms
70,968 KB
testcase_28 AC 70 ms
71,284 KB
testcase_29 AC 76 ms
70,964 KB
testcase_30 AC 71 ms
71,084 KB
testcase_31 AC 69 ms
71,276 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