Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Negationist

Автор Negationist, история, 4 часа назад, По-английски

In the speedbreaker question, why do we need to do: c++ mn[i]=min(mn[i],mn[i-1]),mx[i]=max(mx[i],mx[i-1]);

Full Code

Also, I get why the first condition is necessary for there to be a solutions and I get why the second part of the code finds that good interval, but I'm having a little trouble piecing together the sufficiency of the two to guarantee the right answer. Perhaps this is also why I font understand why you have to do the operations on the mins and maxes too.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
4 часа назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Consider any simple test case like : 6 3 3 3 5 5 there is no 4 in the test case but don't you consider the segment for 4(from l=2 to r=4)? that's why we do mn[i] = min(mn[i], mn[i-1]) and the same for mx