結果

問題 No.1935 Water Simulation
ユーザー 👑 rin204rin204
提出日時 2022-05-13 21:29:01
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 71,536 KB
最終ジャッジ日時 2023-09-29 09:56:44
合計ジャッジ時間 4,020 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,356 KB
testcase_01 AC 73 ms
71,392 KB
testcase_02 AC 73 ms
71,292 KB
testcase_03 AC 73 ms
71,412 KB
testcase_04 AC 73 ms
71,324 KB
testcase_05 AC 75 ms
71,260 KB
testcase_06 AC 75 ms
71,208 KB
testcase_07 AC 75 ms
71,452 KB
testcase_08 AC 75 ms
71,320 KB
testcase_09 AC 75 ms
71,244 KB
testcase_10 AC 76 ms
71,204 KB
testcase_11 AC 73 ms
71,364 KB
testcase_12 AC 75 ms
71,168 KB
testcase_13 AC 73 ms
71,256 KB
testcase_14 AC 74 ms
71,536 KB
testcase_15 AC 74 ms
71,340 KB
testcase_16 AC 74 ms
71,300 KB
testcase_17 AC 74 ms
71,316 KB
testcase_18 AC 74 ms
71,208 KB
testcase_19 AC 74 ms
71,048 KB
testcase_20 AC 72 ms
71,312 KB
testcase_21 AC 74 ms
71,296 KB
testcase_22 AC 75 ms
71,336 KB
testcase_23 AC 74 ms
71,476 KB
testcase_24 AC 74 ms
71,044 KB
testcase_25 AC 75 ms
71,468 KB
testcase_26 AC 73 ms
71,336 KB
testcase_27 AC 75 ms
71,240 KB
testcase_28 AC 75 ms
71,392 KB
testcase_29 AC 74 ms
71,536 KB
testcase_30 AC 74 ms
71,120 KB
testcase_31 AC 75 ms
71,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

V = list(map(int, input().split()))
n = V.pop()

A = [V[0], 0, 0, 0]

def f(p1):
    p2 = (p1 + 1) % 4
    if A[p1] + A[p2] <= V[p2]:
        A[p2] += A[p1]
        A[p1] = 0
    else:
        A[p1] = A[p1] + A[p2] - V[p2]
        A[p2] = V[p2]

def g():
    return ((A[0] * 110 + A[1]) * 110 + A[2]) * 110 + A[3]

se = set()
for i in range(n):
    if i % 4 == 0:
        x = g()
        if x in se:
            for i in range(n % 4):
                f(i)
            break
        else:
            se.add(x)
    f(i % 4)
    

print(*A)

0