結果
問題 | No.1650 Moving Coins |
ユーザー |
|
提出日時 | 2021-12-20 22:43:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 969 bytes |
コンパイル時間 | 613 ms |
コンパイル使用メモリ | 81,536 KB |
実行使用メモリ | 223,180 KB |
最終ジャッジ日時 | 2024-09-15 15:22:15 |
合計ジャッジ時間 | 13,627 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 TLE * 1 -- * 7 |
ソースコード
from collections import dequen = int(input())A = list(map(int, input().split()))B = list(map(int, input().split()))L = [deque() for _ in range(n)]for i in range(n - 1, -1, -1):if A[i] < B[i]:cnt = B[i] - A[i]for j in range(cnt):L[i].append((i + 1, 'R'))elif A[i] > B[i]:cnt = A[i] - B[i]for j in range(cnt):L[i].append((i + 1, 'L'))ANS = []flag = Truewhile flag:flag = Falsefor i in range(n):if L[i]:if L[i][0][1] == 'R':if i < n - 1 and A[i] + 1 == A[i + 1]:continueANS.append(L[i].popleft())A[i] += 1elif L[i][0][1] == 'L':if i > 0 and A[i] - 1 == A[i - 1]:continueANS.append(L[i].popleft())A[i] -= 1flag = Trueprint(len(ANS))for ind, direction in ANS:print(ind, direction)