結果

問題 No.1650 Moving Coins
ユーザー 👑 KazunKazun
提出日時 2021-07-31 18:44:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 148,588 KB
最終ジャッジ日時 2024-04-22 03:27:42
合計ジャッジ時間 8,617 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 34 ms
52,096 KB
testcase_03 AC 125 ms
98,404 KB
testcase_04 AC 110 ms
91,648 KB
testcase_05 AC 138 ms
95,616 KB
testcase_06 AC 144 ms
98,304 KB
testcase_07 AC 143 ms
98,652 KB
testcase_08 AC 204 ms
117,204 KB
testcase_09 AC 196 ms
114,540 KB
testcase_10 AC 199 ms
119,184 KB
testcase_11 AC 204 ms
111,552 KB
testcase_12 AC 180 ms
104,544 KB
testcase_13 AC 173 ms
104,444 KB
testcase_14 AC 194 ms
109,172 KB
testcase_15 AC 178 ms
104,024 KB
testcase_16 AC 221 ms
118,064 KB
testcase_17 AC 213 ms
118,184 KB
testcase_18 AC 228 ms
120,412 KB
testcase_19 AC 253 ms
146,956 KB
testcase_20 AC 250 ms
148,588 KB
testcase_21 AC 236 ms
142,908 KB
testcase_22 AC 262 ms
138,068 KB
testcase_23 AC 266 ms
138,592 KB
testcase_24 AC 123 ms
95,744 KB
testcase_25 AC 127 ms
97,152 KB
testcase_26 AC 145 ms
139,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=["*"]+list(map(int,input().split()))+[10**8]
B=["*"]+list(map(int,input().split()))+[10**8]

D=[0]*(N+2)
for i in range(1,N+1):
    if A[i]<B[i]:
        D[i]=1
    elif A[i]>B[i]:
        D[i]=-1

X=[]
Y=[]
a=D[1]
for i in range(1,N+2):
    if D[i]!=a:
        X.append(Y)
        Y=[]
        a=D[i]
    Y.append(i)

X.append(Y)

Command=[]
for y in X:
    if D[y[0]]==1:
        for z in y[::-1]:
            while A[z]<B[z]:
                Command.append((z,"R"))
                A[z]+=1
    elif D[y[0]]==-1:
        for z in y:
            while A[z]>B[z]:
                Command.append((z,"L"))
                A[z]-=1
    else:
        continue

print(len(Command))
for c in Command:
    print(*c)
0