Why does this solution fail on large inputs?

Правка en3, от bradyawn, 2017-10-15 03:13:11

EDIT: Solved. It was not a problem with data structures, it was a logical error. 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?

Теги question, help

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский bradyawn 2017-10-15 03:13:11 83
en2 Английский bradyawn 2017-10-15 02:19:53 42
en1 Английский bradyawn 2017-10-14 22:52:47 541 Initial revision (published)