結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2021-02-06 11:33:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 680 bytes |
| コンパイル時間 | 398 ms |
| コンパイル使用メモリ | 82,016 KB |
| 実行使用メモリ | 107,848 KB |
| 最終ジャッジ日時 | 2024-07-02 18:29:24 |
| 合計ジャッジ時間 | 6,834 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 WA * 14 |
ソースコード
def merge(x, y):
x.reverse()
y.reverse()
res = []
while x and y:
if x[-1] < y[-1]:
res.append(x.pop())
else:
res.append(~y.pop())
while x:
res.append(x.pop())
while y:
res.append(~y.pop())
return res
N, L = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = merge(A, B)
p = 0
D = [-1] * (2 * N)
for i, c in enumerate(C):
if c >= 0:
p += 1
else:
p -= 1
D[i] = p
m = min(D)
D = [d - m for d in D]
loop = max(D) - 1
walk = -1
for c, d in zip(C, D):
if c < 0 and d == loop:
walk = ~c
print(L*loop + walk)
tktk_snsn