Задача Winecraft от Lists - More Exercises
Условието:
You will be given a sequence of integers, which will represent grapes. On the next line you will be given N - an integer, indicating the growth days. You must increment every integer in the list by 1 N times. However, if one of the grapes’ value is greater than the grape to its left and is also greater than the one to his right, it should steal the values, which would have been incremented to its neighbors, and add them to itself, instead of being incremented by 1 like normal (note: if any of the greater grapes’ neighboring grapes have a value of 0, DON’T decrement it and DON’T add its value to the greater grape).
Lesser grapes don’t get incremented, but instead they have their values decremented by 1 by their neighboring greater grapes, therefore their values get added to the greater grapes.
After you're done with the growing (processed the grapes N times), every grape which has a value, lower than N should be removed.
The process should then repeat, again incrementing everything N times, where the greater grapes steal from the lesser grapes, until your list contains less than N grapes.
After that, print the remaining grapes on the console (one line, space-separated).
Не разбирам логиката в примера:
11 12 14 17 19 12
5
Round 1: 12 13 15 16 21 11
Round 2: 13 14 16 15 23 10
Round 3: 14 13 18 12 25 9 - защо от 15 се получава 12, ако се отдават два пъти по една стойност, т.е. 15-2 би трябвало да даде 13
Round 4: 15 12 20 9 27 8
Round 5: 16 11 22 6 29 7
Remove grapes less or equal to 5 è no grapes
Round 1: 17 10 24 3 31 6
Round 2: 18 9 26 0 33 5
Round 3: 19 8 28 0 34 4 - защо 28, а не 27, при условие, че съседното число е 0, т.е. откъде идва втората стойност, за да стане 28
Round 4: 20 7 30 0 35 3
Round 5: 21 6 32 0 36 2
Remove grapes less or equal to 5 è 0 and 2
Стигнах до 30/100, но явно не разбирам нещо от условието. Ако може за разяснение по него, не за решение. :)
В Джъдж задачата е тук: https://judge.softuni.bg/Contests/Compete/Index/425#5