結果

問題 No.1650 Moving Coins
ユーザー irumo8202irumo8202
提出日時 2022-02-07 11:00:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 569 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 46,164 KB
最終ジャッジ日時 2023-09-02 19:10:53
合計ジャッジ時間 14,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,872 KB
testcase_01 AC 16 ms
7,928 KB
testcase_02 AC 15 ms
7,956 KB
testcase_03 AC 237 ms
21,916 KB
testcase_04 AC 186 ms
18,632 KB
testcase_05 AC 222 ms
20,936 KB
testcase_06 AC 247 ms
22,352 KB
testcase_07 AC 250 ms
22,468 KB
testcase_08 AC 398 ms
37,560 KB
testcase_09 AC 405 ms
38,028 KB
testcase_10 AC 408 ms
38,436 KB
testcase_11 AC 420 ms
39,848 KB
testcase_12 AC 346 ms
34,088 KB
testcase_13 AC 352 ms
34,432 KB
testcase_14 AC 399 ms
37,524 KB
testcase_15 AC 329 ms
33,120 KB
testcase_16 AC 438 ms
39,460 KB
testcase_17 AC 423 ms
38,004 KB
testcase_18 AC 475 ms
41,504 KB
testcase_19 AC 569 ms
46,164 KB
testcase_20 AC 549 ms
45,528 KB
testcase_21 AC 548 ms
45,428 KB
testcase_22 AC 542 ms
45,660 KB
testcase_23 AC 555 ms
45,572 KB
testcase_24 AC 248 ms
22,644 KB
testcase_25 AC 250 ms
22,520 KB
testcase_26 AC 272 ms
39,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


stack = []
ans = []
for i in range(N):
    now_pos = A[i]
    to_pos = B[i]
    move = abs(now_pos - to_pos)
    if A[i + 1] > to_pos:
        if now_pos < to_pos:
            direction = "R"
        else:
            direction = "L"
        for _ in range(move):
            ans.append((i + 1, direction))

        while stack:
            ind, move = stack.pop()
            for _ in range(move):
                ans.append((ind + 1, "R"))
    else:
        stack.append((i, move))

print(len(ans))
for row in ans:
    print(*row)
0