結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-08 11:29:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 548 ms / 2,000 ms |
| コード長 | 1,045 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 41,892 KB |
| 最終ジャッジ日時 | 2024-09-29 18:45:53 |
| 合計ジャッジ時間 | 14,020 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
def main():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ctr = 0
ops = []
large_idx = -1
for idx in range(N):
tmp_idx = idx
if A[tmp_idx] >= B[tmp_idx]:
ctr += A[tmp_idx] - B[tmp_idx]
for cur in range(A[tmp_idx] - B[tmp_idx]):
ops.append((tmp_idx, "L"))
A[tmp_idx] = B[tmp_idx]
continue
if tmp_idx >= large_idx:
large_idx = -1
for shift_idx in range(tmp_idx + 1, N):
if A[shift_idx] >= B[shift_idx]:
large_idx = shift_idx
break
else:
large_idx = N
for idx_2 in reversed(range(tmp_idx, large_idx)):
ctr += B[idx_2] - A[idx_2]
for _ in range(B[idx_2] - A[idx_2]):
ops.append((idx_2, "R"))
A[idx_2] = B[idx_2]
print(ctr)
for op_ in ops:
print(op_[0] + 1, op_[1])
if __name__ == "__main__":
main()