SPOJ HOLI (TLE)

I am trying to solve the Spoj holiday accommodation problem but getting a TLE. can anyone help me optimize it? here is my code https://pastebin.com/dtYme8GH