結果
問題 | No.3016 ハチマキおじさん |
ユーザー |
![]() |
提出日時 | 2025-02-05 05:40:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 995 ms / 2,000 ms |
コード長 | 540 bytes |
コンパイル時間 | 927 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 49,520 KB |
最終ジャッジ日時 | 2025-02-05 05:41:06 |
合計ジャッジ時間 | 20,454 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
N=int(input())A=list(map(int,input().split()))B=list(map(int,input().split()))A.sort()B.sort()SA=[0]for i in range(N-1):SA.append(SA[-1]+abs(B[i]-A[i]))A.reverse()B.reverse()SB=[0]for i in range(N-1):SB.append(SB[-1]+abs(B[i]-A[i]))SB.append(0)SB.append(0)SB.reverse()A.reverse()ANS=1<<60LIST=[]for i in range(len(SA)):x=SA[i]+SB[i+2]if x<ANS:ANS=xLIST=[A[i]]elif x==ANS:LIST.append(A[i])LIST=sorted(set(LIST))print(len(LIST))print(*LIST)