結果

問題 No.1650 Moving Coins
ユーザー shinichishinichi
提出日時 2021-08-21 01:47:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 719 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 263,860 KB
最終ジャッジ日時 2024-04-22 11:16:51
合計ジャッジ時間 10,384 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 37 ms
52,096 KB
testcase_02 AC 38 ms
51,456 KB
testcase_03 AC 154 ms
98,580 KB
testcase_04 AC 132 ms
92,620 KB
testcase_05 AC 143 ms
96,512 KB
testcase_06 AC 163 ms
98,612 KB
testcase_07 AC 155 ms
98,696 KB
testcase_08 AC 200 ms
103,720 KB
testcase_09 AC 240 ms
103,876 KB
testcase_10 AC 207 ms
103,356 KB
testcase_11 AC 255 ms
103,604 KB
testcase_12 AC 197 ms
93,664 KB
testcase_13 AC 214 ms
94,600 KB
testcase_14 AC 249 ms
103,216 KB
testcase_15 AC 217 ms
92,408 KB
testcase_16 AC 270 ms
104,832 KB
testcase_17 AC 259 ms
104,076 KB
testcase_18 AC 301 ms
103,140 KB
testcase_19 AC 719 ms
263,860 KB
testcase_20 AC 237 ms
110,700 KB
testcase_21 AC 485 ms
182,840 KB
testcase_22 AC 248 ms
109,720 KB
testcase_23 AC 243 ms
109,640 KB
testcase_24 AC 147 ms
98,688 KB
testcase_25 AC 153 ms
98,944 KB
testcase_26 AC 117 ms
107,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

result = []


sys.setrecursionlimit(1000000)
def dfs(i):
    while A[i] != B[i]:
        if A[i]-B[i] > 0:
            if i == 0 or A[i-1] != A[i] - 1:
                A[i] -= 1
                result.append((i+1, "L"))
            else:
                dfs(i-1)
        else:
            if i == N-1 or A[i+1] != A[i] + 1:
                A[i] += 1
                result.append((i+1, "R"))
            else:
                dfs(i+1)

for i in range(N):
    dfs(i)
print(len(result))
for res in result:
    print(*res)
0