結果

問題 No.1650 Moving Coins
ユーザー hayatroid
提出日時 2021-08-20 22:37:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 578 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 108,672 KB
最終ジャッジ日時 2024-10-14 04:40:23
合計ジャッジ時間 5,412 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

d = list(range(n))

ans = 0
rec = []
while d:
  for i in d:
    if a[i] == b[i]:
      d.pop(d.index(i))
      continue
    if d.index(i) != 0:
      if a[d[d.index(i) - 1]] >= b[d[d.index(i)]]:
        continue
    if d.index(i) != len(d) - 1:
      if a[d[d.index(i) + 1]] <= b[d[d.index(i)]]:
        continue
    for j in range(abs(a[i] - b[i])):
      ans += 1
      rec.append(str(i + 1) + ' ' + ('L' if a[i] > b[i] else 'R'))
    d.pop(d.index(i))

print(ans)
print(*rec, sep='\n')
0