結果

問題 No.1650 Moving Coins
ユーザー rlangevinrlangevin
提出日時 2023-01-15 11:26:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 510 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 54,896 KB
最終ジャッジ日時 2023-08-27 19:12:06
合計ジャッジ時間 12,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,876 KB
testcase_01 AC 15 ms
7,896 KB
testcase_02 AC 16 ms
7,944 KB
testcase_03 AC 259 ms
21,700 KB
testcase_04 AC 224 ms
18,624 KB
testcase_05 AC 240 ms
20,896 KB
testcase_06 AC 263 ms
22,296 KB
testcase_07 AC 263 ms
22,212 KB
testcase_08 AC 338 ms
34,448 KB
testcase_09 AC 381 ms
34,416 KB
testcase_10 AC 350 ms
35,256 KB
testcase_11 AC 382 ms
35,588 KB
testcase_12 AC 325 ms
29,840 KB
testcase_13 AC 331 ms
30,132 KB
testcase_14 AC 357 ms
34,012 KB
testcase_15 AC 318 ms
28,036 KB
testcase_16 AC 387 ms
36,400 KB
testcase_17 AC 375 ms
35,424 KB
testcase_18 AC 398 ms
38,608 KB
testcase_19 AC 510 ms
54,896 KB
testcase_20 AC 430 ms
45,572 KB
testcase_21 AC 463 ms
45,512 KB
testcase_22 AC 434 ms
45,600 KB
testcase_23 AC 432 ms
45,704 KB
testcase_24 AC 343 ms
22,436 KB
testcase_25 AC 311 ms
22,496 KB
testcase_26 AC 161 ms
39,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)

def dfs(i):
    while A[i] != B[i]:
        if A[i] > B[i]:
            ans.append((i, "L"))
            A[i] -= 1
        else:
            if A[i + 1] == A[i] + 1:
                dfs(i + 1)
            else:
                ans.append((i, "R"))
                A[i] += 1
    return 


N = int(input())
A = list(map(int, input().split())) + [10 ** 18]
B = list(map(int, input().split()))

ans = []
for i in range(N):
    dfs(i)
print(len(ans))
for k, c in ans:
    print(k + 1, c)
0