Logo
(追記) (追記ここまで)

23703번 - Anatoly Shalyto 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB1176100.000%

문제

Median of a multiset of integers is the smallest integer $X$ such that at least half of the elements of the set are less than or equal to $X$.

Mode of a multiset of integers is the value that occurs the most times in the multiset. If there are multiple such values the mode is the smallest.

Imbalance of a multiset is the absolute difference between the median and the mode.

A multiset $T$ is a subset of a multiset $S$ if for every value the number of its occurrences in $S$ isn't less than the number of its occurrences in $T$.

You are given a multiset of integers. Consider its non-empty subset with the largest imbalance. Print that imbalance.

입력

The first line contains a single integer $n$ (1ドル \leq n \leq 10^5$), size of the multiset.

The second line contains $n$ integers $a_i$ (0ドル \leq a_i < 10^9, a_i \leq a_{i+1},ドル elements of the multiset.

출력

Print a single integer --- the largest imbalance of some subset of the given multiset.

제한

예제 입력 1

4
1 2 8 8

예제 출력 1

6

예제 입력 2

5
2 2 2 8 8

예제 출력 2

0

예제 입력 3

5
1 2 3 4 5

예제 출력 3

3

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 16: Grand Prix of Moscow A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /