結果
問題 |
No.3268 As Seen in Toasters
|
ユーザー |
![]() |
提出日時 | 2025-09-12 21:46:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 696 bytes |
コンパイル時間 | 1,729 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 32,836 KB |
最終ジャッジ日時 | 2025-09-12 23:37:27 |
合計ジャッジ時間 | 11,515 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 RE * 6 |
ソースコード
import sys input = sys.stdin.readline N=int(input()) A=list(map(int,input().split())) A.sort() def calc(x,y): if x<0 and y<0: return -x-y else: return abs(x-y) def calc2(A): score=0 for i in range(N-1): x,y=A[i],A[i+1] score+=calc(x,y) return score MIN=calc2(A) ind=A[:] MINUS=[] OTHER=[] for a in A: if a<0: MINUS.append(a) else: OTHER.append(a) B=[-1]*len(OTHER) f=0 l=len(B)-1 for i in range(len(OTHER)): if i%2==0: B[f]=OTHER[i] f+=1 else: B[l]=OTHER[i] l-=1 B=[MINUS[0]]+B+MINUS[1:][::-1] score2=calc2(B) if score2<MIN: MIN=score2 ind=B[:] print(MIN)