結果
| 問題 | No.3268 As Seen in Toasters |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-09-12 21:46:32 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 696 bytes |
| 記録 | |
| コンパイル時間 | 464 ms |
| コンパイル使用メモリ | 21,540 KB |
| 実行使用メモリ | 37,020 KB |
| 最終ジャッジ日時 | 2026-07-15 00:37:28 |
| 合計ジャッジ時間 | 12,336 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
titia