結果

問題 No.1650 Moving Coins
ユーザー chocoruskchocorusk
提出日時 2021-07-18 04:36:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 148,280 KB
最終ジャッジ日時 2024-04-22 03:25:38
合計ジャッジ時間 9,227 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,968 KB
testcase_01 AC 38 ms
51,584 KB
testcase_02 AC 39 ms
51,584 KB
testcase_03 AC 150 ms
98,048 KB
testcase_04 AC 130 ms
91,648 KB
testcase_05 AC 148 ms
95,872 KB
testcase_06 AC 157 ms
99,072 KB
testcase_07 AC 156 ms
98,688 KB
testcase_08 AC 225 ms
117,480 KB
testcase_09 AC 218 ms
114,920 KB
testcase_10 AC 222 ms
119,172 KB
testcase_11 AC 225 ms
111,796 KB
testcase_12 AC 203 ms
104,300 KB
testcase_13 AC 203 ms
104,496 KB
testcase_14 AC 225 ms
109,620 KB
testcase_15 AC 192 ms
103,904 KB
testcase_16 AC 243 ms
118,384 KB
testcase_17 AC 243 ms
117,956 KB
testcase_18 AC 258 ms
120,152 KB
testcase_19 AC 260 ms
146,564 KB
testcase_20 AC 262 ms
148,280 KB
testcase_21 AC 266 ms
143,660 KB
testcase_22 AC 284 ms
137,936 KB
testcase_23 AC 284 ms
138,472 KB
testcase_24 AC 145 ms
95,488 KB
testcase_25 AC 154 ms
97,152 KB
testcase_26 AC 150 ms
139,516 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