This is is a problem from the 2011 USP Try-outs(http://codeforces.com/gym/101081/problem/I) and I cannot view my output for the test cases. I saw it as a job sequencing problem and solved it using greedy. But I am getting TLE on test case 35: http://codeforces.com/gym/101081/submission/21429116. Is my approach wrong? The time limit should be ample for 1<= n <= 10^5 hence I don't understand why I am getting TLE? Any helps would be highly appreciated! Thanks

Use Priority Queue to solve.