Anyone wants to debate about Longest Saw ?
# codeforces
a
Anyone wants to debate about Longest Saw ?
e
What you want to debate about it?
a
I read the solution, but I would like to know more how they could get into the solution, like first interactions of the solution. Reading the solution and the tutorial wasn’t clear enough for me hehe. I would like to know like how they thought 💭 about greedy, it is some similar problem ? I really wouldn’t never get to the solution without seeing it.
e
The usual approach to think about greedy problems goes like this.
First you look at a potential solution. Then you think how it can be improved. So, if somebody gave you a saw and one of the “ups” is lower than “down” then you can flip them and get another solution. Repeating this process you can always get a solution where all ups are higher than all downs.
Now it is obvious that “larger” “ups” and “lower” “downs” are better. So you can always take the largest values of arrays as ups and lowest as down.
But you don’t know how many of them to take. Here you use a standard approach called “binary search”.
a
thanks 😄