Codeforces Round #377 Div. 2 review

Link

A. Buy a Shovel

It can be paid without change if the change is 0 or \(r\).

B. Cormen — The Best Friend Of a Man

At day \(i\), dog need to walk \( k-a[i-1] \) times.

C. Sanatorium

Basic idea to the solution is not difficult, just check all the popssibility of what time start eating (enter room) and what time end eating (exit room). But the corner case handling makes this problem difficult and I cannot answer correctly in one time.

Rather than below, more elegant/ short code solution can be found at pekempey’s solution.

D. Exams

Use binary search. Fix the duration \(x\) days, and we can check if it is possible to pass all the tests in \(x\) days or not. 

In each check it costs \( O(N) \), so in total it takes \( O(N\log N) \) to find the solution.

 

 

 

 

 

 

Sponsored Links

Leave a Reply

Your email address will not be published.