結果

問題 No.1650 Moving Coins
ユーザー ayaoniayaoni
提出日時 2021-08-20 23:04:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 590 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 266,468 KB
最終ジャッジ日時 2024-04-22 07:09:32
合計ジャッジ時間 10,845 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
59,392 KB
testcase_01 AC 45 ms
59,648 KB
testcase_02 AC 45 ms
59,904 KB
testcase_03 AC 261 ms
88,572 KB
testcase_04 AC 159 ms
85,376 KB
testcase_05 AC 241 ms
88,228 KB
testcase_06 AC 245 ms
87,936 KB
testcase_07 AC 204 ms
87,424 KB
testcase_08 AC 188 ms
104,960 KB
testcase_09 AC 229 ms
112,256 KB
testcase_10 AC 183 ms
105,644 KB
testcase_11 AC 263 ms
105,472 KB
testcase_12 AC 277 ms
100,864 KB
testcase_13 AC 227 ms
100,544 KB
testcase_14 AC 316 ms
112,512 KB
testcase_15 AC 391 ms
96,128 KB
testcase_16 AC 352 ms
107,520 KB
testcase_17 AC 367 ms
105,856 KB
testcase_18 AC 248 ms
112,512 KB
testcase_19 AC 590 ms
266,468 KB
testcase_20 AC 205 ms
118,364 KB
testcase_21 AC 405 ms
184,460 KB
testcase_22 AC 230 ms
117,608 KB
testcase_23 AC 228 ms
116,992 KB
testcase_24 AC 128 ms
84,608 KB
testcase_25 AC 141 ms
84,736 KB
testcase_26 AC 129 ms
116,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
A = LI()
B = LI()
flag = [0]*(10**6+1)
for a in A:
    flag[a] += 1

ans = sum(abs(a-b) for a,b in zip(A,B))
print(ans)


def right(x,i):  # xにあるコインを1つ右に
    if flag[x+1]:
        right(x+1,i+1)
    flag[x] = 0
    flag[x+1] = 1
    print(i,'R')
    A[i-1] += 1


for i in range(N):
    a = A[i]
    b = B[i]
    if a >= b:
        for _ in range(a-b):
            print(i+1,'L')
    else:
        for j in range(a,b):
            right(j,i+1)
0