Problem Description
Loading...
Problem Analysis
The problem statement is a bit hard to understand
It is essentially finding the largest “mountain” shape
That is, a shape that is first non-decreasing and then non-increasing
Once you understand the problem,
the code is easy to write
cpp
| |
Problem link:【CodeForces】[66B]Petya and Countryside
Meaning:
Find the longest subarray in the given array that satisfies
first non-decreasing and then non-increasing
i.e., a shape like “1223221”
Solution process
Since we need a subarray that is first non-decreasing and then non-increasing
we can simulate this process
starting from each number and scanning forward
record the maximum length that can be reached
and thus update the maximum value