Before reading the editorial, please make sure you've read the problem thoroughly multiple times and tried your best to solve it. Thanks!
Proceed to Editorial
Store two maps - the first map to store when each waiting person sent their message, and the second map to store the total wait time of each person. Then, process the instructions in pairs (so for instructions `A B C`, process as `AB, BC, C_`). Only carry out the action from the first instruction - if it is an `R` operation, add that person to the wait-list map; if it is an `S` operation, add the current time minus their wait-list value to the total wait time and delete that person from the wait-list, and if it is a `W` operation, increase the current time by that value. Finally, if neither of the instructions in the pair is a `W` operation, increment the time.