結果
問題 |
No.808 Kaiten Sushi?
|
ユーザー |
![]() |
提出日時 | 2021-02-06 11:58:49 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 782 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 107,816 KB |
最終ジャッジ日時 | 2024-07-02 18:52:40 |
合計ジャッジ時間 | 7,018 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 RE * 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 mx = max(D) mn = min(D) if mx == 0: ans = L * (mx - mn) + B[0] else: D = [d - mn 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 ans = L*loop + walk print(ans)