Editorial for Back to School '24 P2 - Cheating
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1:
We can put all students in a queue starting with points. For each question , we add to the score of the first students, and move the students to the end of the queue.
Time Complexity:
Subtask 2:
We can further optimize our solution from subtask 1 by noticing that it is not required to iterate through the queue's values individually to add score. We can store the index of the first student in the queue as index , which is originally . We can then notice that for each question , we will increase the score of the students in the range of to (where this range may wrap from end to start), and the new would be . We can further optimize this increase by using a difference array to answer the queries.
Time Complexity:
Comments