結果

問題 No.1650 Moving Coins
ユーザー ayaoniayaoni
提出日時 2021-08-20 23:01:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,078 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 442,008 KB
最終ジャッジ日時 2024-04-22 07:00:26
合計ジャッジ時間 10,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
65,280 KB
testcase_01 AC 41 ms
59,776 KB
testcase_02 AC 44 ms
59,776 KB
testcase_03 AC 190 ms
100,908 KB
testcase_04 AC 159 ms
95,872 KB
testcase_05 AC 196 ms
102,428 KB
testcase_06 AC 199 ms
98,840 KB
testcase_07 AC 177 ms
99,328 KB
testcase_08 AC 184 ms
119,168 KB
testcase_09 AC 260 ms
113,316 KB
testcase_10 AC 185 ms
119,296 KB
testcase_11 AC 261 ms
107,520 KB
testcase_12 AC 270 ms
103,132 KB
testcase_13 AC 232 ms
102,784 KB
testcase_14 AC 286 ms
113,336 KB
testcase_15 AC 273 ms
102,140 KB
testcase_16 AC 298 ms
111,488 KB
testcase_17 AC 261 ms
111,616 KB
testcase_18 AC 269 ms
112,384 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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


def right(x,i):  # xにあるコインを1つ右に
    res = []
    if flag[x+1]:
        R = right(x+1,i+1)
        for r in R:
            res.append(r)
    flag[x] = 0
    flag[x+1] = 1
    res.append((i,'R'))
    A[i-1] += 1
    return res


ANS = []
for i in range(N):
    a = A[i]
    b = B[i]
    if a >= b:
        for _ in range(a-b):
            ANS.append((i+1,'L'))
    else:
        for j in range(a,b):
            X = right(j,i+1)
            for x in X:
                ANS.append(x)

print(len(ANS))
for k,c in ANS:
    print(k,c)
0