結果
| 問題 |
No.1767 BLUE to RED
|
| コンテスト | |
| ユーザー |
hir355
|
| 提出日時 | 2021-11-26 23:06:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 276 ms / 2,000 ms |
| コード長 | 377 bytes |
| コンパイル時間 | 161 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 138,460 KB |
| 最終ジャッジ日時 | 2024-06-29 18:30:04 |
| 合計ジャッジ時間 | 5,845 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
from bisect import bisect_left
m, n = map(int, input().split())
b = list(map(int, input().split()))
a = list(map(int, input().split()))
c = a + b
c.sort()
ans = max(c) - min(c) + 1 - m
for i in range(m - 1):
l = bisect_left(c, b[i])
r = bisect_left(c, b[i + 1])
res = 0
for j in range(l, r):
res = max(res, c[j + 1] - c[j] - 1)
ans -= res
print(ans)
hir355