Starving Priority Queue

Back to Problem Solutions forum

Y_VICTORY     2020-08-03 18:14:58
User avatar

Why i have wrong answer Input : 10037 99 Correct answer : 10411732961 My answer : 10409042975

qwerty     2020-08-03 21:42:35

If you read problem statement carefully, you probably noticed that:

"Note that on even-numbered seconds monks at first distribute food among the visitors already waiting in the queue and only then receive a newcomer."

So just swap in your program first if statement and block (receiving newcomer) with second if statement + block (food distribution) and you should get right answer.

P. S. Yeah, for example provided in problem statement original program makes right answer, but it is just luck :)...

Y_VICTORY     2020-08-04 02:34:33
User avatar

thank you qwerty-one, i have done solve this problem :)

Please login and solve 5 problems to be able to post at forum