#BS0000409. Giải Rubik tốc độ (Expeditious Cubing)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Giải Rubik tốc độ (Expeditious Cubing)
Expeditious Cubing
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Claire competes in timed solving of the Rubik's cube. Each contestant completes five solves. Once all five are completed, one fastest and one slowest time are discarded. The score is the mean of the remaining three times; a smaller score is better.
Claire's first four solve times are seconds. From the other contestants' results, she knows a target score : she wins if her score is at most .
Determine whether Claire can still win. If she can, find the largest time she may spend on her last solve while still winning. If she wins regardless of the last solve time, report that instead.
Input
The first line contains four real numbers , the first four solve times in seconds.
The second line contains the real number , the target score in seconds.
Output
Print exactly one line:
impossibleif Claire cannot win.infiniteif Claire wins regardless of her final solve time.- Otherwise, print the maximum last solve time that still allows Claire to win, with exactly two digits after the decimal point.
Subtasks
- Subtask 1 (20 points): (); ; all five numbers have exactly two decimal digits; .
- Subtask 2 (30 points): (); ; all five numbers have exactly two decimal digits; the four times contain at most two distinct values.
- Subtask 3 (50 points): (); ; all five numbers have exactly two decimal digits.
Examples
Input
6.38 7.20 6.95 8.11
7.53
Output
infinite
Explanation
Sorted times are . A last time of at least yields . A smaller last time cannot increase the score, so Claire always wins.
Input
6.38 7.20 6.95 8.11
6.99
Output
6.82
Explanation
At , discard and . The remaining times sum to , giving mean . A larger final time below increases that sum, and a time at least gives . No larger time can win.
Input
6.38 7.20 6.95 8.11
6.45
Output
impossible
Explanation
Even with a final time at most , the retained times are . The minimum possible score is , so winning is impossible.