10. Poisonous Plants от Stacks and Queues - Exercise /в архивите/ - 88/100 в Judge

Здравейте, колеги,

От известно време забих на тази задача. Успях да я докарам до 88/100, но вече каквото и да опитам, не мога да разбера защо тест 3 гърми.

Някой може ли да ми помогне да си открия грешката в решението?


Problem 10. Poisonous Plants

You are given N plants in a garden. Each of these plants has been added with some amount of pesticide. After each day, if any plant has more pesticide than the plant at its left, being weaker (more GMO) than the left one, it dies. You are given the initial values of the amount of pesticide and the position of each plant. Print the number of days after which no plant dies, i.e. the time after which there are no plants with more pesticide content than the plant to their left.

Input Format:

  • The input consists of an integer N representing the number of plants
  • The next single line consists of N integers where every integer represents the position and the amount of pesticides of each plant

Output Format:

  • Output a single value equal to the number of days after which no plants die


  • 1 ≤ N ≤ 100000
  • Pesticides amount on a plant is between 0 and 1000000000





6 5 8 4 7 10 9



Initially all plants are alive. 
Plants = {(6,1), (5,2), (8,3), (4,4), (7,5), (10,6), (9,7)}.
Plants[k] = (i,j) => jth plant has pesticide amount = i.
After the 1st day, 4 plants remain as plants 3, 5, and 6 die.
Plants = {(6,1), (5,2), (4,4), (9,7)}.
After the 2nd day, 3 plants survive as plant 7 dies. Plants = {(6,1), (5,2), (4,4)}.
After the 3rd day, 3 plants survive, and no more plants die.
Plants = {(6,1), (5,2), (4,4)}.
After the 2nd day the plants stop dying.