結果
問題 | No.1767 BLUE to RED |
ユーザー |
![]() |
提出日時 | 2021-11-26 22:35:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 215 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 135 ms |
コンパイル使用メモリ | 82,512 KB |
実行使用メモリ | 148,520 KB |
最終ジャッジ日時 | 2024-06-29 18:14:12 |
合計ジャッジ時間 | 4,822 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) A.append(10 ** 10) C = [] for a in A: C.append((a, 0)) for b in B: C.append((b, 1)) C.sort(key=lambda x: x[0]) ans = 0 st = [-10 ** 10] for x, y in C: if y == 0: st.append(x) ans += st[-1] - st[0] - 1 ma = 0 for i in range(len(st) - 1): ma = max(ma, st[i+1] - st[i] - 1) ans -= ma st = [x] else: st.append(x) print(ans) if __name__ == '__main__': main()