結果

問題 No.1650 Moving Coins
ユーザー 👑 KazunKazun
提出日時 2021-07-17 20:23:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 148,024 KB
最終ジャッジ日時 2024-04-22 03:25:56
合計ジャッジ時間 8,693 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,968 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 39 ms
51,584 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 262 ms
146,944 KB
testcase_20 AC 266 ms
148,024 KB
testcase_21 AC 283 ms
138,540 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 147 ms
95,616 KB
testcase_25 AC 153 ms
97,152 KB
testcase_26 AC 158 ms
139,764 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=[]
    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