結果

問題 No.1650 Moving Coins
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-08-20 21:53:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 679 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 285,812 KB
最終ジャッジ日時 2023-08-04 06:17:19
合計ジャッジ時間 16,042 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,268 KB
testcase_01 AC 74 ms
71,272 KB
testcase_02 AC 73 ms
71,152 KB
testcase_03 AC 170 ms
96,428 KB
testcase_04 AC 160 ms
91,260 KB
testcase_05 AC 182 ms
94,540 KB
testcase_06 AC 197 ms
96,444 KB
testcase_07 AC 188 ms
96,888 KB
testcase_08 AC 426 ms
195,444 KB
testcase_09 AC 410 ms
192,344 KB
testcase_10 AC 423 ms
199,156 KB
testcase_11 AC 451 ms
201,936 KB
testcase_12 AC 323 ms
149,584 KB
testcase_13 AC 346 ms
154,436 KB
testcase_14 AC 409 ms
192,504 KB
testcase_15 AC 297 ms
139,636 KB
testcase_16 AC 463 ms
214,528 KB
testcase_17 AC 479 ms
217,640 KB
testcase_18 AC 544 ms
232,380 KB
testcase_19 AC 679 ms
284,992 KB
testcase_20 AC 679 ms
285,812 KB
testcase_21 AC 634 ms
284,928 KB
testcase_22 AC 659 ms
284,656 KB
testcase_23 AC 626 ms
284,708 KB
testcase_24 AC 178 ms
96,668 KB
testcase_25 AC 181 ms
96,752 KB
testcase_26 AC 474 ms
271,804 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