結果

問題 No.1650 Moving Coins
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-08-20 21:53:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,484 KB
実行使用メモリ 278,792 KB
最終ジャッジ日時 2024-04-22 04:23:16
合計ジャッジ時間 13,221 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,584 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 39 ms
51,584 KB
testcase_03 AC 132 ms
95,744 KB
testcase_04 AC 134 ms
90,112 KB
testcase_05 AC 153 ms
93,716 KB
testcase_06 AC 154 ms
95,872 KB
testcase_07 AC 158 ms
95,488 KB
testcase_08 AC 372 ms
191,104 KB
testcase_09 AC 386 ms
182,828 KB
testcase_10 AC 375 ms
194,312 KB
testcase_11 AC 403 ms
195,452 KB
testcase_12 AC 281 ms
143,620 KB
testcase_13 AC 297 ms
147,840 KB
testcase_14 AC 394 ms
180,864 KB
testcase_15 AC 294 ms
135,932 KB
testcase_16 AC 447 ms
210,688 KB
testcase_17 AC 412 ms
211,200 KB
testcase_18 AC 443 ms
224,512 KB
testcase_19 AC 545 ms
273,872 KB
testcase_20 AC 534 ms
276,696 KB
testcase_21 AC 541 ms
278,792 KB
testcase_22 AC 563 ms
277,976 KB
testcase_23 AC 589 ms
278,100 KB
testcase_24 AC 131 ms
95,616 KB
testcase_25 AC 143 ms
95,616 KB
testcase_26 AC 443 ms
265,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline  # 文字列入力はするな!!
import sys
sys.setrecursionlimit(10**9)

n=int(input())
a=[-10**18]+list(map(int,input().split()))+[10**18]
b=[-10**18]+list(map(int,input().split()))+[10**18]
ans=[]
ok=set()
def f(i):
    if a[i]<b[i]:
        for j in range(b[i]-a[i]):ans.append((i,"R"))
    else:
        for j in range(a[i]-b[i]):ans.append((i,"L"))
    ok.add(i)

def g(i):
    if i==n+1:return
    if a[i]>=b[i]:
        f(i)
        g(i+1)
    else:
        if a[i+1]>b[i]:
            f(i)
            g(i+1)
        else:
            g(i+1)
            f(i)

g(1)
print(len(ans))
for x,y in ans:
    print(x,y)




0