Editorial for TLE '16 Contest 5 P5 - Better Ranking List
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, print the maximum score so far for the first problem. This subtask was intended to reward users who read all of the problems.
Time Complexity: 
For the second subtask, perform the instructions listed in the problem statement. Keep an array which stores the highest submissions for each problem, sort a copy of this array, and calculate the PP.
Time Complexity: 
For the third subtask, notice that . Then the user's PP is equal to 
. In this formula, sorting is not needed. For each query, find the increase in the total sum, then output the total sum.
Time Complexity: 
For the fourth subtask, it is only necessary to get the user's top  submissions. All of the other submissions are covered by the relative error, since 
. Record the problems which are in the top 
, and update this small list when necessary.
Time Complexity: 
The fifth subtask is intended to reward submissions which are not fast enough to solve the sixth subtask. Some reasons include:
- using 
long doubleinstead ofdouble - calculating the powers of 
every time (instead of using an array)
 - runtime is slower than 
 
For the sixth subtask, it is important to know about merging two lists of scores. Let  be the final list, and 
 where 
 and 
 are smaller lists. Suppose all of the elements in 
 are equal/greater than the elements in 
, and the PP for 
 and 
 are known. Then the PP for 
 can be calculated easily by this formula:
Then segment trees can be used to quickly update the PP. First, keep an array of all  pairs, then sort the array by 
. At the very beginning, the leaves of the segment tree are all set to size 
, since there are no submissions yet. For every update, the old leaf needs to be set to size 
, and the new leaf set to size 
. Every node contains its own PP and size, and the user's PP can be found at the root of the segment tree. Make sure to keep another array which stores 
 so that the formula is efficient. Lazy propagation is not needed.
To do this problem onlinely, it is possible to use a balanced binary search tree (BBST) and the formula described above (except with a slight modification). Every node contains a PP, and lazy propagation is not needed because every node can store its size. I don't see a way to use pb_ds, sorry .
Time Complexity: 
Comments