結果

問題 No.3016 ハチマキおじさん
コンテスト
ユーザー Koi
提出日時 2025-01-25 12:58:04
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 507 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 550 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 137,604 KB
最終ジャッジ日時 2026-06-23 21:05:16
合計ジャッジ時間 5,800 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
ans = set()
ans_v = 0

for i in range(N - 1):
    ans_v += abs(A[i] - B[i])
now = ans_v
ans = {A[N - 1]}
for i in range(N - 2, -1, -1):
    # print(i, now, ans, A[i])
    now -= abs(A[i] - B[i])
    now += abs(A[i + 1] - B[i])
    # print(i, A[i], now)
    if(now == ans_v):
        ans.add(A[i])
    elif(now < ans_v):
        ans = {A[i]}
        ans_v = now
print(len(ans))
print(*sorted(list(ans)))
0