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

G. Great Expectations

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

A speedrun is a playthrough of a game with the intention to complete it as quickly as possible. When speedrunning, you usually follow a pre-planned path through the game. Along this path, there may be some places where you have to pull off a difficult technique, or trick, which may cause a delay if you fail to pull it off successfully. Luckily you can reset the game at any time: if you have made a few mistakes, you can start a new run, losing your progress but instantaneously starting over with a clean slate. You can do this as often as you like.

The game you are currently speedrunning has a record of \(r\) seconds, which you intend to beat. You have discovered a path through the game that, in the best case, takes \(n < r\) seconds. There are some tricks along the way, though: you know exactly where along the run they occur, what the probability is that you will pull them off successfully, and how many seconds you have to spend to recover if they fail.

Given this data, you want to find the optimal strategy for when to reset the game to minimise the expected time to set a new record. Write a program to determine what this smallest possible expected time is.

제약
입력 형식

The input consists of:
- One line with three integers \(n\), \(r\) and \(m\) (\(2 \leq n < r \leq 5\,000\), \(1 \le m \le 50\)), where \(n\) and \(r\) are as described above and \(m\) is the number of tricks.
- \(m\) lines, each containing three numbers describing a trick:
- An integer \(t\) (\(1 \le t < n\)), the time in the route (assuming no failed tricks before) at which the trick occurs,
- a real number \(p\) (\(0 < p < 1\) and \(p\) has at most \(6\) digits after the decimal point), the probability that the trick succeeds, and
- an integer \(d\) (\(1 \le d \le 1\,000\)), the number of seconds required to recover in case the trick fails.

The tricks are given in sorted order by \(t\), and no two tricks occur at the same time \(t\) in the route.

You may assume that, without resetting, a single playthrough has a probability of at least \(1\) in \(50\,000\) to succeed at improving the record.

출력 형식

Output the expected time you will have to play the game to set a new record, assuming an optimal strategy is used. Your answer should have an absolute or relative error of at most \(10^{-6}\).

예제 1
입력
100 111 5
20 0.5 10
80 0.5 2
85 0.5 2
90 0.5 2
95 0.5 2
출력
124
예제 2
입력
2 4 1
1 0.5 5
출력
3
예제 3
입력
10 20 3
5 0.3 8
6 0.8 3
8 0.9 3
출력
18.9029850746
예제 4
입력
10 50 1
5 0.5 30
출력
15
문제 정보

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

출처 ICPC NWERC 2020

평가 및 의견

G. Great Expectations

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

Log in to rate problems.

개별 의견

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

풀이 제출

G. Great Expectations

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