結果

問題 No.1650 Moving Coins
ユーザー H3PO4H3PO4
提出日時 2021-08-20 21:56:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 590 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 48,584 KB
最終ジャッジ日時 2024-04-22 04:27:48
合計ジャッジ時間 14,089 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 303 ms
24,448 KB
testcase_04 AC 238 ms
21,120 KB
testcase_05 AC 284 ms
23,424 KB
testcase_06 AC 309 ms
24,704 KB
testcase_07 AC 311 ms
24,960 KB
testcase_08 AC 444 ms
39,880 KB
testcase_09 AC 450 ms
41,420 KB
testcase_10 AC 455 ms
40,764 KB
testcase_11 AC 463 ms
42,036 KB
testcase_12 AC 399 ms
36,708 KB
testcase_13 AC 406 ms
36,672 KB
testcase_14 AC 446 ms
40,768 KB
testcase_15 AC 392 ms
35,280 KB
testcase_16 AC 484 ms
41,800 KB
testcase_17 AC 464 ms
41,092 KB
testcase_18 AC 504 ms
42,164 KB
testcase_19 AC 590 ms
48,584 KB
testcase_20 AC 577 ms
46,896 KB
testcase_21 AC 585 ms
47,536 KB
testcase_22 AC 587 ms
48,172 KB
testcase_23 AC 585 ms
48,164 KB
testcase_24 AC 310 ms
25,088 KB
testcase_25 AC 317 ms
25,088 KB
testcase_26 AC 220 ms
38,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


ans = []
def move(i):
    x, y = A[i], B[i]
    if x < y:
        for _ in range(y - x):
            ans.append((i + 1, 'R'))
    elif x > y:
        for _ in range(x - y):
            ans.append((i + 1, 'L'))

stk = []
for i, (a, b) in enumerate(zip(A, B)):
    if a < b:
        stk.append(i)
    elif a > b:
        while stk:
            j = stk.pop()
            move(j)
        move(i)
while stk:
    j = stk.pop()
    move(j)

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