結果
問題 | No.1650 Moving Coins |
ユーザー |
![]() |
提出日時 | 2021-08-20 21:47:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 241 ms / 2,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 131,476 KB |
最終ジャッジ日時 | 2024-10-14 03:11:21 |
合計ジャッジ時間 | 9,203 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import sysinput = sys.stdin.readlineN=int(input())A=list(map(int,input().split()))B=list(map(int,input().split()))ANS=[]while A!=B:for i in range(N):if A[i]<B[i]:while A[i]<B[i] and (i+1==N or A[i+1]!=A[i]+1):ANS.append((i+1,"R"))A[i]+=1elif A[i]>B[i]:while A[i]>B[i] and (i==0 or A[i-1]!=A[i]-1):ANS.append((i+1,"L"))A[i]-=1for i in range(N-1,-1,-1):if A[i]<B[i]:while A[i]<B[i] and (i+1==N or A[i+1]!=A[i]+1):ANS.append((i+1,"R"))A[i]+=1elif A[i]>B[i]:while A[i]>B[i] and (i==0 or A[i-1]!=A[i]-1):ANS.append((i+1,"L"))A[i]-=1print(len(ANS))for x,y in ANS:print(x,y)