Delivery Problem! Zomato!
I have seen this question were k = 2 and I solved it in O(n) but here...
Codeforces Edu Round 190 (Div 2) — Solution Discussion