結果

問題 No.1650 Moving Coins
ユーザー irumo8202
提出日時 2022-02-07 11:00:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 606 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 49,680 KB
最終ジャッジ日時 2024-06-12 01:36:32
合計ジャッジ時間 13,984 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split())) + [10 ** 9]
B = list(map(int, input().split()))


stack = []
ans = []
for i in range(N):
    now_pos = A[i]
    to_pos = B[i]
    move = abs(now_pos - to_pos)
    if A[i + 1] > to_pos:
        if now_pos < to_pos:
            direction = "R"
        else:
            direction = "L"
        for _ in range(move):
            ans.append((i + 1, direction))

        while stack:
            ind, move = stack.pop()
            for _ in range(move):
                ans.append((ind + 1, "R"))
    else:
        stack.append((i, move))

print(len(ans))
for row in ans:
    print(*row)
0