結果

問題 No.1650 Moving Coins
ユーザー huka_hukahuka_huka
提出日時 2021-08-22 07:35:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 82,700 KB
実行使用メモリ 113,408 KB
最終ジャッジ日時 2024-04-23 21:00:14
合計ジャッジ時間 9,219 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,840 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 36 ms
51,584 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 144 ms
103,168 KB
testcase_09 WA -
testcase_10 AC 144 ms
103,692 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 RE -
testcase_20 AC 168 ms
110,716 KB
testcase_21 RE -
testcase_22 AC 178 ms
109,748 KB
testcase_23 AC 178 ms
110,140 KB
testcase_24 AC 90 ms
95,284 KB
testcase_25 AC 94 ms
95,360 KB
testcase_26 AC 119 ms
108,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# yc1650
def solver(i, m):
    if a[i]-b[i] < 0:
        while a[i] < b[i]:
            if i+1 < n and a[i+1] == a[i]+1:
                m += solver(i+1, m)
            a[i] += 1
            m += 1
            ans.append(str(i+1)+" R")
    elif a[i]-b[i] > 0:
        while a[i] > b[i]:
            if i-1 >= 0 and a[i] == a[i-1]+1:
                m += solver(i-1, m)
            a[i] -= 1
            m += 1
            ans.append(str(i+1)+" L")
    return m
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
m = 0
for i in range(n):
    m += solver(i, 0)
print(m)
for i in ans:
    print(i)
0