RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03569

S5. Josh’s Double Bacon Deluxe

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

On their way to the contest grounds, Josh, his coach, and his \(N-2\) teammates decide to stop at a burger
joint that offers \(M\) distinct burger
menu items. After ordering their favourite burgers, the team members
line up, with the coach in the first position and Josh last, to pick up
their burgers. Unfortunately, the coach forgot what he ordered. He picks
a burger at random and walks away. The other team members, in sequence,
pick up their favourite burger if available, or a random remaining
burger if there are no more of their favourite burger. What is the
probability that Josh, being last in line, will get to eat his favourite
burger?

제약

\((3\leq N\leq 1~000~000)\)
\((1\leq b_i\leq M\leq 500~000)\)
\(N\leq 100~000\)
\(M\leq 1000\)
\(M\leq 5000\)

입력 형식

The first line contains the number \(N\) \((3\leq N\leq 1~000~000)\), the total number of people and burgers. The
next line contains \(N\) numbers, the
\(i\)-th being \(b_i\) \((1\leq b_i\leq M\leq 500~000)\), denoting the item number of the \(i\)-th person’s favourite burger. The first
person in line is the coach, and the \(N\)-th person is Josh.

For 4 of the 15 available marks, \(N\leq 100~000\) and \(M\leq 1000\).

For an additional 5 of the 15 available marks, \(M\leq 5000\).

출력 형식

Output a single number \(P\), the
probability that Josh will get to eat his favourite burger, \(b_N\). If the correct answer is \(C\), the grader will view \(P\) correct if \(|P-C|<10^{-6}\).

예제 1
입력
3
1 2 3
출력
0.5
설명

The coach randomly chooses between the three burgers. With probability
\(1/3\), he chooses his favourite
burger (burger 1), and Josh gets to eat his favourite burger (burger 3).
With probability \(1/3\), he chooses
Josh’s favourite burger, and Josh fails to eat his favourite burger.
With probability \(1/3\), he chooses
the second person’s burger, there is a \(1/2\) chance that the second person chooses
Josh’s burger, denying Josh the pleasure of eating his favourite
burger.

예제 2
입력
7
1 2 3 1 1 2 3
출력
0.57142857
문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2020 Senior

평가 및 의견

S5. Josh’s Double Bacon Deluxe

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

S5. Josh’s Double Bacon Deluxe

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8