Why does this solution fail on large inputs?

Revision en2, by bradyawn, 2017-10-15 02:19:53

I've been doing this greedy problem, and my solution fails on test case 6. For small inputs it seems to work, but for large inputs it produces strange results.

Problem: 854C - Planning

My Solution: https://pastebin.com/MQBNBHEJ

Someone else's accepted solution: 30195313 — They used a priority_queue while I used a sorted vector. This should achieve the same result, and I do not think it is the data structure that is the problem.

Any idea what the problem might be?

Tags question, help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English bradyawn 2017-10-15 03:13:11 83
en2 English bradyawn 2017-10-15 02:19:53 42
en1 English bradyawn 2017-10-14 22:52:47 541 Initial revision (published)