結果
問題 |
No.3016 ハチマキおじさん
|
ユーザー |
![]() |
提出日時 | 2025-09-06 10:59:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 273 ms / 2,000 ms |
コード長 | 1,162 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 134,540 KB |
最終ジャッジ日時 | 2025-09-06 10:59:38 |
合計ジャッジ時間 | 9,436 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
from heapq import heappop, heappush, heapify from bisect import bisect #from sortedcontainers import SortedList from collections import deque, defaultdict from math import floor, ceil, isqrt, comb from sys import stdin, setrecursionlimit #setrecursionlimit(10**7) intin = lambda: int(stdin.readline()) strin = lambda: stdin.readline().rstrip() listin = lambda: list(map(int, stdin.readline().split())) tuplein = lambda m: [tuple(map(lambda x: int(x) if x.isdigit() or (len(x) > 1 and x[0] == "-" and x[1:].isdigit()) else x, stdin.readline().split())) for _ in range(m)] gridin = lambda m: [list(map(int, stdin.readline().split())) for _ in range(m)] strgridin = lambda h: [stdin.readline().rstrip() for _ in range(h)] mapin = lambda: map(int, stdin.readline().split()) N = intin() A = listin() B = listin() ans = set() tmp = 0 A.sort(); B.sort() for a, b in zip(A[1:], B): tmp += abs(a - b) ans.add(A[0]) minimum = tmp for i in range(1, N): tmp -= abs(A[i] - B[i-1]) tmp += abs(A[i-1] - B[i-1]) if minimum > tmp: minimum = tmp ans = {A[i]} elif minimum == tmp: ans.add(A[i]) print(len(ans)) print(*sorted(list(ans)))