結果

問題 No.1935 Water Simulation
ユーザー lloyzlloyz
提出日時 2022-05-13 22:04:49
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,128 bytes
コンパイル時間 56 ms
使用メモリ 7,904 KB
最終ジャッジ日時 2023-02-21 18:49:36
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 15 ms
7,860 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 15 ms
7,696 KB
testcase_03 AC 15 ms
7,780 KB
testcase_04 AC 15 ms
7,776 KB
testcase_05 AC 15 ms
7,820 KB
testcase_06 AC 15 ms
7,868 KB
testcase_07 AC 15 ms
7,688 KB
testcase_08 AC 15 ms
7,688 KB
testcase_09 AC 15 ms
7,904 KB
testcase_10 AC 16 ms
7,732 KB
testcase_11 AC 14 ms
7,756 KB
testcase_12 AC 15 ms
7,760 KB
testcase_13 AC 15 ms
7,688 KB
testcase_14 AC 15 ms
7,648 KB
testcase_15 AC 15 ms
7,784 KB
testcase_16 AC 15 ms
7,896 KB
testcase_17 AC 14 ms
7,688 KB
testcase_18 AC 16 ms
7,780 KB
testcase_19 AC 15 ms
7,792 KB
testcase_20 AC 15 ms
7,732 KB
testcase_21 AC 16 ms
7,788 KB
testcase_22 AC 15 ms
7,648 KB
testcase_23 AC 15 ms
7,744 KB
testcase_24 AC 14 ms
7,788 KB
testcase_25 AC 15 ms
7,900 KB
testcase_26 AC 14 ms
7,736 KB
testcase_27 AC 15 ms
7,664 KB
testcase_28 AC 15 ms
7,852 KB
testcase_29 AC 14 ms
7,856 KB
testcase_30 AC 15 ms
7,808 KB
testcase_31 AC 14 ms
7,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

if len(sys.argv) == 2:
    sys.stdin = open(sys.argv[1])

v1, v2, v3, v4, n = map(int, input().split())

cnt = 0
ANS = [v1, 0, 0, 0]
L = []
flag = False
while n > 0:
    if cnt % 4 == 0:
        if ANS[0] + ANS[1] <= v2:
            ANS[1] += ANS[0]
            ANS[0] = 0
        else:
            ANS[0] -= v2 - ANS[1]
            ANS[1] = v2
    elif cnt % 4 == 1:
        if ANS[1] + ANS[2] <= v3:
            ANS[2] += ANS[1]
            ANS[1] = 0
        else:
            ANS[1] -= v3 - ANS[2]
            ANS[2] = v3
    elif cnt % 4 == 2:
        if ANS[2] + ANS[3] <= v4:
            ANS[3] += ANS[2]
            ANS[2] = 0
        else:
            ANS[2] -= v4 - ANS[3]
            ANS[3] = v4
    else:
        if ANS[3] + ANS[0] <= v1:
            ANS[0] += ANS[3]
            ANS[3] = 0
        else:
            ANS[3] -= v1 - ANS[0]
            ANS[0] = v1
    cnt += 1
    n -= 1
    if len(L) < 4:
        L.append(ANS[:])
    else:
        if L[0] == ANS:
            flag = True
            break
        L = L[1:]
        L.append(ANS[:])
if flag:
    print(*L[n % 4])
else:
    print(*L[-1])
0