結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2021-08-20 21:52:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 612 ms / 2,000 ms |
| コード長 | 754 bytes |
| コンパイル時間 | 193 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 66,748 KB |
| 最終ジャッジ日時 | 2024-10-14 03:23:46 |
| 合計ジャッジ時間 | 10,175 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
U = 10 ** 7
N = int(input())
A = [-1] + list(map(int, input().split())) + [U]
B = [-1] + list(map(int, input().split())) + [U]
answer = []
i = 0
while i <= N:
while i <= N and A[i] == B[i]:
i += 1
# 左寄せ
while i <= N and A[i] > B[i]:
answer.append((i, B[i] - A[i]))
i += 1
while i <= N and A[i] == B[i]:
i += 1
# 右寄せ
tmp = []
while i <= N and A[i] < B[i]:
tmp.append((i, B[i] - A[i]))
i += 1
answer.extend(tmp[::-1])
ans = []
cnt = 0
for i, d in answer:
if d > 0:
direction = "R"
else:
d = -d
direction = "L"
cnt += d
ans.extend(
["{} {}".format(i, direction)] * d
)
print(len(ans))
print("\n".join(ans))
tktk_snsn