結果

問題 No.1935 Water Simulation
ユーザー lloyzlloyz
提出日時 2022-05-13 22:04:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,128 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,044 KB
実行使用メモリ 8,372 KB
最終ジャッジ日時 2023-09-29 10:01:17
合計ジャッジ時間 1,866 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,196 KB
testcase_01 AC 17 ms
8,196 KB
testcase_02 AC 17 ms
8,252 KB
testcase_03 AC 16 ms
8,240 KB
testcase_04 AC 15 ms
8,116 KB
testcase_05 AC 16 ms
8,272 KB
testcase_06 AC 16 ms
8,208 KB
testcase_07 AC 16 ms
8,208 KB
testcase_08 AC 16 ms
8,200 KB
testcase_09 AC 16 ms
8,232 KB
testcase_10 AC 15 ms
8,108 KB
testcase_11 AC 16 ms
8,116 KB
testcase_12 AC 16 ms
8,228 KB
testcase_13 AC 16 ms
8,204 KB
testcase_14 AC 16 ms
8,372 KB
testcase_15 AC 16 ms
8,180 KB
testcase_16 AC 16 ms
8,200 KB
testcase_17 AC 15 ms
8,204 KB
testcase_18 AC 16 ms
8,204 KB
testcase_19 AC 16 ms
8,232 KB
testcase_20 AC 16 ms
8,212 KB
testcase_21 AC 16 ms
8,220 KB
testcase_22 AC 16 ms
8,200 KB
testcase_23 AC 16 ms
8,192 KB
testcase_24 AC 16 ms
8,276 KB
testcase_25 AC 15 ms
8,276 KB
testcase_26 AC 16 ms
8,192 KB
testcase_27 AC 16 ms
8,200 KB
testcase_28 AC 15 ms
8,184 KB
testcase_29 AC 16 ms
8,112 KB
testcase_30 AC 15 ms
8,192 KB
testcase_31 AC 16 ms
7,908 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