結果

問題 No.1935 Water Simulation
ユーザー ikomaikoma
提出日時 2022-05-13 22:26:55
言語 PyPy3
(7.3.11)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 75,160 KB
最終ジャッジ日時 2023-07-08 08:39:41
合計ジャッジ時間 3,909 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
75,160 KB
testcase_01 AC 73 ms
75,148 KB
testcase_02 AC 66 ms
71,568 KB
testcase_03 AC 69 ms
71,336 KB
testcase_04 AC 71 ms
71,464 KB
testcase_05 AC 72 ms
71,144 KB
testcase_06 AC 71 ms
71,268 KB
testcase_07 AC 67 ms
71,336 KB
testcase_08 AC 67 ms
71,444 KB
testcase_09 AC 66 ms
71,132 KB
testcase_10 AC 66 ms
71,412 KB
testcase_11 AC 65 ms
71,280 KB
testcase_12 AC 72 ms
71,284 KB
testcase_13 AC 72 ms
71,660 KB
testcase_14 AC 68 ms
71,608 KB
testcase_15 AC 70 ms
71,340 KB
testcase_16 AC 70 ms
71,368 KB
testcase_17 AC 67 ms
71,564 KB
testcase_18 AC 68 ms
71,284 KB
testcase_19 AC 67 ms
71,468 KB
testcase_20 AC 66 ms
71,448 KB
testcase_21 AC 69 ms
71,284 KB
testcase_22 AC 66 ms
71,320 KB
testcase_23 AC 70 ms
71,132 KB
testcase_24 AC 70 ms
71,288 KB
testcase_25 AC 65 ms
71,452 KB
testcase_26 AC 69 ms
71,412 KB
testcase_27 AC 71 ms
71,568 KB
testcase_28 AC 66 ms
71,288 KB
testcase_29 AC 66 ms
71,620 KB
testcase_30 AC 69 ms
71,080 KB
testcase_31 AC 67 ms
71,336 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