Editorial for DMOPC '19 Contest 5 P4 - Cafeteria Confrontation Conundrum
Submitting an official solution before solving the problem yourself is a bannable offence.
Subtask 1
For the first subtask, it suffices to simply brute force everything: for every query, iterate over every person and calculate the total amount of money you can get from each chain. Stop when you reach a chain that has enough money.
Time complexity:
Subtask 2
For the second subtask, we can note that instead of recomputing the sum of each chain for every query, we can preprocess it. Preprocessing takes
Time complexity:
Subtask 3
The intended solution for this subtask is to construct and prefix maximum array from the sum array described in Subtask 2 (which can also be done in
Time complexity:
Comments