結果
| 問題 |
No.2304 Distinct Elements
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2023-05-16 07:55:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 761 ms / 3,000 ms |
| コード長 | 380 bytes |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 32,708 KB |
| 最終ジャッジ日時 | 2024-12-14 09:57:19 |
| 合計ジャッジ時間 | 24,020 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 58 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
N=int(input())
A=list(map(int,input().split()))
A.sort()
for i in range(N):
A[i]-=i
L=[10**18]
R=[10**18]
MIN=0
for a in A:
heappush(R,a)
x=heappop(R)
MIN+=abs(x-a)
heappush(L,-x)
heappush(L,-a)
x=-heappop(L)
heappush(R,x)
MIN+=abs(x-a)
R=[10**18]
print(MIN)
titia