結果
問題 | No.1650 Moving Coins |
ユーザー | lloyz |
提出日時 | 2021-12-20 22:43:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 969 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 86,996 KB |
実行使用メモリ | 191,928 KB |
最終ジャッジ日時 | 2023-10-13 19:36:05 |
合計ジャッジ時間 | 16,852 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
71,752 KB |
testcase_01 | AC | 91 ms
71,736 KB |
testcase_02 | AC | 91 ms
71,872 KB |
testcase_03 | AC | 245 ms
97,804 KB |
testcase_04 | AC | 212 ms
90,892 KB |
testcase_05 | AC | 235 ms
94,468 KB |
testcase_06 | AC | 247 ms
98,692 KB |
testcase_07 | AC | 253 ms
99,400 KB |
testcase_08 | AC | 390 ms
171,180 KB |
testcase_09 | AC | 552 ms
162,312 KB |
testcase_10 | AC | 391 ms
173,700 KB |
testcase_11 | AC | 594 ms
170,264 KB |
testcase_12 | AC | 411 ms
140,988 KB |
testcase_13 | AC | 467 ms
142,264 KB |
testcase_14 | AC | 523 ms
164,704 KB |
testcase_15 | AC | 329 ms
132,088 KB |
testcase_16 | AC | 428 ms
181,100 KB |
testcase_17 | AC | 434 ms
183,108 KB |
testcase_18 | AC | 463 ms
191,928 KB |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
from collections import deque n = 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 = True while flag: flag = False for i in range(n): if L[i]: if L[i][0][1] == 'R': if i < n - 1 and A[i] + 1 == A[i + 1]: continue ANS.append(L[i].popleft()) A[i] += 1 elif L[i][0][1] == 'L': if i > 0 and A[i] - 1 == A[i - 1]: continue ANS.append(L[i].popleft()) A[i] -= 1 flag = True print(len(ANS)) for ind, direction in ANS: print(ind, direction)