結果

問題 No.1650 Moving Coins
ユーザー ThetaTheta
提出日時 2024-03-08 11:29:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 536 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 42,220 KB
最終ジャッジ日時 2024-03-08 11:30:14
合計ジャッジ時間 15,909 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,984 KB
testcase_01 AC 52 ms
9,984 KB
testcase_02 AC 30 ms
9,984 KB
testcase_03 AC 246 ms
23,808 KB
testcase_04 AC 188 ms
20,480 KB
testcase_05 AC 225 ms
22,784 KB
testcase_06 AC 268 ms
24,064 KB
testcase_07 AC 245 ms
24,192 KB
testcase_08 AC 340 ms
34,104 KB
testcase_09 AC 389 ms
33,588 KB
testcase_10 AC 354 ms
34,600 KB
testcase_11 AC 366 ms
34,980 KB
testcase_12 AC 336 ms
29,828 KB
testcase_13 AC 316 ms
30,360 KB
testcase_14 AC 363 ms
33,312 KB
testcase_15 AC 301 ms
28,796 KB
testcase_16 AC 380 ms
35,340 KB
testcase_17 AC 398 ms
33,912 KB
testcase_18 AC 403 ms
37,296 KB
testcase_19 AC 535 ms
42,220 KB
testcase_20 AC 438 ms
41,308 KB
testcase_21 AC 490 ms
41,308 KB
testcase_22 AC 511 ms
39,968 KB
testcase_23 AC 536 ms
39,968 KB
testcase_24 AC 246 ms
24,320 KB
testcase_25 AC 247 ms
24,320 KB
testcase_26 AC 205 ms
39,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ctr = 0
    ops = []
    large_idx = -1
    for idx in range(N):
        tmp_idx = idx
        if A[tmp_idx] >= B[tmp_idx]:
            ctr += A[tmp_idx] - B[tmp_idx]
            for cur in range(A[tmp_idx] - B[tmp_idx]):
                ops.append((tmp_idx, "L"))
            A[tmp_idx] = B[tmp_idx]

            continue
        if tmp_idx >= large_idx:
            large_idx = -1
            for shift_idx in range(tmp_idx + 1, N):
                if A[shift_idx] >= B[shift_idx]:
                    large_idx = shift_idx
                    break
            else:
                large_idx = N
        for idx_2 in reversed(range(tmp_idx, large_idx)):
            ctr += B[idx_2] - A[idx_2]
            for _ in range(B[idx_2] - A[idx_2]):
                ops.append((idx_2, "R"))
            A[idx_2] = B[idx_2]
    print(ctr)
    for op_ in ops:
        print(op_[0] + 1, op_[1])


if __name__ == "__main__":
    main()
0