[CF] 279B - Books

Easy question but I thought of it in a too difficult way.
My Solution
Idea: Notice that for each i
th book, we just need to find r_i
such that the sum of the time from i
to r_i
th book is smaller than t
. We can also notice that r_i is not descending, so each time we calculate r_i
from r_{i-1}
1 |
Official Solution
Similar Idea but much more descent code.
Thoughts
You shouldn’t solve a question from strange or fancy techniques. Try solving a question from the most bruteforce way and gradually decrease the question.