結果

問題 No.1935 Water Simulation
ユーザー roarisroaris
提出日時 2022-05-14 18:33:10
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 1,010 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 74,612 KB
最終ジャッジ日時 2023-09-30 10:35:56
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,032 KB
testcase_01 AC 76 ms
74,612 KB
testcase_02 AC 74 ms
70,924 KB
testcase_03 AC 74 ms
70,884 KB
testcase_04 AC 75 ms
70,808 KB
testcase_05 AC 73 ms
70,696 KB
testcase_06 AC 75 ms
71,120 KB
testcase_07 AC 74 ms
70,804 KB
testcase_08 AC 74 ms
70,864 KB
testcase_09 AC 74 ms
70,920 KB
testcase_10 AC 73 ms
71,036 KB
testcase_11 AC 74 ms
70,920 KB
testcase_12 AC 74 ms
71,000 KB
testcase_13 AC 78 ms
71,020 KB
testcase_14 AC 73 ms
70,904 KB
testcase_15 AC 78 ms
70,692 KB
testcase_16 AC 77 ms
70,916 KB
testcase_17 AC 73 ms
70,912 KB
testcase_18 AC 73 ms
70,596 KB
testcase_19 AC 74 ms
70,872 KB
testcase_20 AC 74 ms
70,952 KB
testcase_21 AC 73 ms
71,064 KB
testcase_22 AC 75 ms
70,920 KB
testcase_23 AC 74 ms
70,684 KB
testcase_24 AC 74 ms
70,872 KB
testcase_25 AC 75 ms
71,028 KB
testcase_26 AC 74 ms
70,916 KB
testcase_27 AC 72 ms
70,916 KB
testcase_28 AC 74 ms
71,064 KB
testcase_29 AC 73 ms
70,808 KB
testcase_30 AC 73 ms
70,872 KB
testcase_31 AC 76 ms
71,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

V1, V2, V3, V4, N = map(int, input().split())
V = [V1, V2, V3, V4]
now = [V1, 0, 0, 0]
s = {tuple(now)}

for i in range(N):
    if now[i%4]+now[(i+1)%4]<=V[(i+1)%4]:
        now[i%4], now[(i+1)%4] = 0, now[i%4]+now[(i+1)%4]
    else:
        now[i%4], now[(i+1)%4] = now[i%4]-V[(i+1)%4]+now[(i+1)%4], V[(i+1)%4]
    
    if i%4==3:
        if tuple(now) in s:
            for j in range(N%(i+1)):
                if now[j%4]+now[(j+1)%4]<=V[(j+1)%4]:
                    now[j%4], now[(j+1)%4] = 0, now[j%4]+now[(j+1)%4]
                else:
                    now[j%4], now[(j+1)%4] = now[j%4]-V[(j+1)%4]+now[(j+1)%4], V[(j+1)%4]
            
            exit(print(*now))
        
        s.add(tuple(now))

print(*now)
0