結果

問題 No.1650 Moving Coins
ユーザー tcltk
提出日時 2021-10-17 05:54:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 152,264 KB
最終ジャッジ日時 2024-09-17 19:37:02
合計ジャッジ時間 12,849 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """2
# 1 2
# 2 4
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

wait = False
q = []
result = []
for i in range(N):
    if A[i] < B[i]:
        for _ in range(B[i]-A[i]):
            q.append((i+1, 'R'))
    else:
        while q:
            result.append(q.pop())
        for _ in range(A[i]-B[i]):
            result.append((i+1, 'L'))
while q:
    result.append(q.pop())

print(len(result))
for i, c in result:
    print(i, c)


0