solved.ac 2022 difficulty rating
Time limit2sMemory limit1024 MB
Given N timestamped difficulty opinions (levels 1 to 30), compute a weighted average where newer opinions and the 0.9 per-rank decay raise weight, rounded to an integer.
- Level
Easy3 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
solved.ac is a community project that assigns difficulty ratings to problems on a programming problem-solving site. Before, the problems on that site had no difficulty labels, so it was hard to judge how hard a problem was before trying it. solved.ac was created to fix this. Since its launch, more than 1,900 contributors have shared difficulty opinions, and about 16,000 problems now have a rating.
The difficulty of a problem is decided from the difficulty opinions that users submitted for it. Previously, the difficulty was a simple trimmed mean that ignored when each opinion was submitted. Programming problem solving changes quickly, so solved.ac changed the formula to give newer opinions more weight. When a problem receives difficulty opinions, its difficulty is decided as follows.
- If there are no difficulty opinions, the difficulty of the problem is .
- If there is at least one opinion, sort the opinions by submission time. Then the weight of each opinion is given by the following formula.
- is the time when the -th difficulty opinion was submitted. Since the opinions are sorted by time, , and is the time of the most recent opinion.
- The difficulty of the problem is the weighted average with weights , rounded to an integer at the first digit after the decimal point.
- is the difficulty in the -th opinion, converted to an integer from to . means Bronze 5, the lowest difficulty, and means Ruby 1, the highest difficulty.
Input
The first line contains the number of difficulty opinions .
From the second line, the next lines each contain one difficulty opinion. The -th of these lines contains and , separated by a space.
-
is the time when the difficulty opinion was submitted. It is in the format year/month/day hour:minute:second.
- The year has 4 digits. The month, day, hour, minute, and second each have 2 digits, and a leading may be added to fill the width. In particular, is a leap year, so February has 29 days in .
- Time uses the 24-hour format.
- The given times range from 00:00:00 on June 6, 2019 to 23:59:59 on July 1, 2022. The times are sorted so that .
-
is the difficulty value of the opinion, an integer.
Output
Print the difficulty calculated from the given opinions. The answer is accepted if the printed integer differs from the unrounded weighted average computed by the checker by at most .
Hint
In the first case, the first opinion was submitted about 834 days and 6 hours, or about years, before the last opinion. So the weighted average is Rounding this gives , which is the difficulty.