結果

問題 No.1650 Moving Coins
ユーザー huka_huka
提出日時 2021-08-22 07:35:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,284 KB
実行使用メモリ 113,528 KB
最終ジャッジ日時 2024-11-06 03:18:50
合計ジャッジ時間 9,657 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 14 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

# yc1650
def solver(i, m):
    if a[i]-b[i] < 0:
        while a[i] < b[i]:
            if i+1 < n and a[i+1] == a[i]+1:
                m += solver(i+1, m)
            a[i] += 1
            m += 1
            ans.append(str(i+1)+" R")
    elif a[i]-b[i] > 0:
        while a[i] > b[i]:
            if i-1 >= 0 and a[i] == a[i-1]+1:
                m += solver(i-1, m)
            a[i] -= 1
            m += 1
            ans.append(str(i+1)+" L")
    return m
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
m = 0
for i in range(n):
    m += solver(i, 0)
print(m)
for i in ans:
    print(i)
0