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

19263번 - Game of Chairs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB33191760.714%

문제

You are participating in a strange game. There are $n$ chairs in a row at a distance of one meter from each other. Each chair is painted by one of $c$ different colors.

At the beginning, you can sit on any chair. Then the jury will choose a color and announce it. Each color has $\frac{1}{c}$ probability to be chosen. Your task is to move to any chair of this color.

Of course, you will move to the nearest appropriate chair. If you are already sitting on it, you will not move at all.

You want to pick a chair to sit at the beginning to minimize the expected distance which you will have to walk.

입력

In the first line there are two integers $n$ and $c$: the number of chairs and the number of colors (1ドル \leq c \leq n \leq 10^6$).

The second line contains $n$ integers $a_i$: the colors of chairs (1ドル \leq a_i \leq c$). There is at least one chair of each color.

출력

Output the expected distance as an irreducible fraction.

제한

예제 입력 1

5 3
1 1 2 3 1

예제 출력 1

2/3

예제 입력 2

5 5
1 2 3 4 5

예제 출력 2

6/5

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2018 > Day 2: ITMO U 1 Contest G번

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

출처

대학교 대회

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

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