結果

問題 No.1650 Moving Coins
ユーザー kohei2019
提出日時 2022-06-28 23:21:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 646 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 320,636 KB
最終ジャッジ日時 2024-11-21 18:29:36
合計ジャッジ時間 10,032 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
N = int(input())
lsA = list(map(int,input().split()))
lsB = list(map(int,input().split()))

moves = []
def moveto(n,k):
    if lsA[n] == k:
        return
    if n == N-1:
        while lsA[n] != k:
            moves.append((n,'R'))
            lsA[n] += 1

    else:
        while lsA[n] != k:
            if lsA[n]+1 == lsA[n+1]:
                moveto(n+1,lsA[n+1]+1)
                moves.append((n,'R'))
                lsA[n] += 1
            else:
                moves.append((n,'R'))
                lsA[n] += 1


for i in range(N):
    move = lsB[i]-lsA[i]
    now = lsA[i]
    if move <= 0:
        while move != 0:
            moves.append((i,'L'))
            move += 1
    else:
        stac = []
        moveto(i,lsB[i])

print(len(moves))
for a,b in moves:
    print(a+1,b)
0