Under construction

Still being built. Things may change

solved.ac 2022 difficulty rating

Time limit2sMemory limit1024 MB

Summary
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 NN difficulty opinions, its difficulty is decided as follows.

  • If there are no difficulty opinions, the difficulty of the problem is 00.
  • If there is at least one opinion, sort the opinions by submission time. Then the weight pip_i of each opinion is given by the following formula. pi=max⁡(0.5(tN−ti)/365 days,0.9N−i)p_i=\max\left(0.5^{(t_N-t_i)/365\text{ days}},0.9^{N-i}\right)
    • tit_i is the time when the ii-th difficulty opinion was submitted. Since the opinions are sorted by time, t1≤t2≤⋯≤tNt_1\le t_2\le\cdots\le t_N, and tNt_N is the time of the most recent opinion.
  • The difficulty XX of the problem is the weighted average with weights pip_i, rounded to an integer at the first digit after the decimal point. X=p1l1+p2l2+⋯+pNlNp1+p2+⋯+pN=∑i=1Npili∑i=1NpiX=\frac{p_1l_1+p_2l_2+\cdots+p_Nl_N}{p_1+p_2+\cdots+p_N}=\frac{\sum_{i=1}^{N}p_il_i}{\sum_{i=1}^{N}p_i}
    • lil_i is the difficulty in the ii-th opinion, converted to an integer from 11 to 3030. 11 means Bronze 5, the lowest difficulty, and 3030 means Ruby 1, the highest difficulty.

Input

The first line contains the number of difficulty opinions NN. (0≤N≤1 000)(0\le N\le 1\,000)

From the second line, the next NN lines each contain one difficulty opinion. The ii-th of these lines contains tit_i and lil_i, separated by a space.

  • tit_i 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 00 may be added to fill the width. In particular, 20202020 is a leap year, so February has 29 days in 20202020.
    • 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 t1≤t2≤⋯≤tNt_1\le t_2\le\cdots\le t_N.
  • lil_i is the difficulty value of the opinion, an integer. (1≤li≤30)(1\le l_i\le 30)

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 0.5+10−5=0.500010.5+10^{-5}=0.50001.

Hint

In the first case, the first opinion was submitted about 834 days and 6 hours, or about 2.2862.286 years, before the last opinion. So the weighted average is X≈max⁡(0.52.286,0.91)×24+max⁡(0.50,0.90)×18max⁡(0.52.286,0.91)+max⁡(0.50,0.90)=0.9×24+1×180.9+1≈20.842X\approx\frac{\max\left(0.5^{2.286},0.9^1\right)\times 24+\max\left(0.5^0,0.9^0\right)\times 18}{\max\left(0.5^{2.286},0.9^1\right)+\max\left(0.5^0,0.9^0\right)}=\frac{0.9\times 24+1\times 18}{0.9+1}\approx 20.842 Rounding this gives 2121, which is the difficulty.

Examples3

  1. Example 1

    Input
    2
    2019/07/03 03:43:21 24
    2021/10/14 10:12:31 18
    
    Expected output
    21
    
  2. Example 2

    Input
    3
    2020/08/01 22:41:52 24
    2020/08/02 09:20:19 26
    2020/08/15 15:17:53 24
    
    Expected output
    25
    
  3. Example 3

    Input
    0
    
    Expected output
    0