結果

問題 No.1650 Moving Coins
コンテスト
ユーザー kohei2019
提出日時 2022-06-28 23:21:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 829 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 142 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 336,564 KB
最終ジャッジ日時 2026-05-15 22:16:35
合計ジャッジ時間 8,051 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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