codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

66B.md (2008B)


      1 Source: https://codeforces.com/problemset/problem/66/B
      2 
      3 B. Petya and Countryside
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × *n* in size, when viewed from above. This rectangle is divided into *n* equal square sections. The garden is very unusual as each of the square sections possesses its own fixed height and due to the newest irrigation system we can create artificial rain above each section.
     22 
     23 Creating artificial rain is an expensive operation. That's why we limit ourselves to creating the artificial rain only above one section. At that, the water from each watered section will flow into its neighbouring sections if their height does not exceed the height of the section. That is, for example, the garden can be represented by a 1 × 5 rectangle, where the section heights are equal to 4, 2, 3, 3, 2. Then if we create an artificial rain over any of the sections with the height of 3, the water will flow over all the sections, except the ones with the height of 4. See the illustration of this example at the picture:
     24 
     25  ![](https://espresso.codeforces.com/5013775b92cea2a80739b22bf9fa8b0f07012cfa.png) 
     26 
     27 As Petya is keen on programming, he decided to find such a section that if we create artificial rain above it, the number of watered sections will be maximal. Help him.
     28 
     29 Input
     30 
     31 The first line contains a positive integer *n* (1 ≤ *n* ≤ 1000). The second line contains *n* positive integers which are the height of the sections. All the numbers are no less than 1 and not more than 1000.
     32 
     33 Output
     34 
     35 Print a single number, the maximal number of watered sections if we create artificial rain above exactly one section.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 1  
     43 2
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 1
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 5  
     56 1 2 1 2 1
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 3
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 8  
     69 1 2 1 1 1 3 3 4
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 6
     76 ```