Editorial
Maintain the current rating . Read the performances in order and update each time. Every updated rating is guaranteed to be an integer, so no rounding rule is needed.
Initially, . If after processing the -th performance, applying the given formula to the next performance makes . By induction, after all contests .
Because and are at most , the numerator is at most . Thus, every calculation fits in a 32-bit signed integer.
The same method applies to subtask 1. Its condition means that the rating does not decrease, but the update formula is unchanged. Across either subtask, the total time complexity is and the extra space complexity is when the input is streamed.
Solution written by GPT5