結果

問題 No.1650 Moving Coins
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-08-21 08:15:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 129,440 KB
最終ジャッジ日時 2024-04-22 17:55:50
合計ジャッジ時間 8,875 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,096 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 35 ms
52,096 KB
testcase_03 AC 100 ms
77,172 KB
testcase_04 AC 104 ms
77,456 KB
testcase_05 AC 113 ms
77,376 KB
testcase_06 AC 121 ms
78,004 KB
testcase_07 AC 126 ms
77,652 KB
testcase_08 AC 200 ms
108,300 KB
testcase_09 AC 192 ms
103,552 KB
testcase_10 AC 201 ms
109,724 KB
testcase_11 AC 248 ms
110,080 KB
testcase_12 AC 183 ms
93,048 KB
testcase_13 AC 186 ms
92,672 KB
testcase_14 AC 225 ms
103,552 KB
testcase_15 AC 175 ms
90,112 KB
testcase_16 AC 275 ms
114,380 KB
testcase_17 AC 275 ms
115,284 KB
testcase_18 AC 290 ms
120,000 KB
testcase_19 AC 264 ms
129,440 KB
testcase_20 AC 266 ms
128,860 KB
testcase_21 AC 270 ms
127,284 KB
testcase_22 AC 273 ms
126,520 KB
testcase_23 AC 269 ms
126,520 KB
testcase_24 AC 102 ms
77,056 KB
testcase_25 AC 122 ms
77,568 KB
testcase_26 AC 113 ms
108,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = []
kaisu = 0
flg = 0
q_flg = 0
cnt = 0
for i in range(n):
    if a[i] == b[i]:
        cnt += 1
        continue
    kaisu += abs(a[i] - b[i])
    flg = 1 if a[i] > b[i] else -1
    if q_flg != flg:
        ren = 1
        cnt += 1
    else:
        ren += 1
    l.append((i+1,flg * ren,cnt))
    q_flg = flg
print(kaisu)
l.sort(key = lambda x :(x[2],x[1]))
for i,ren,cnt in l:
    mark = "R" if a[i-1] < b[i-1] else "L"
    for j in range(abs(a[i-1] - b[i-1])):
        print(i,mark)
0