codeforces-scrape

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

446A.md (1183B)


      1 Source: https://codeforces.com/problemset/problem/446/A
      2 
      3 A. DZY Loves Sequences
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 DZY has a sequence *a*, consisting of *n* integers.
     22 
     23 We'll call a sequence *a**i*, *a**i* + 1, ..., *a**j* (1 ≤ *i* ≤ *j* ≤ *n*) a subsegment of the sequence *a*. The value (*j* - *i* + 1) denotes the length of the subsegment.
     24 
     25 Your task is to find the longest subsegment of *a*, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.
     26 
     27 You only need to output the length of the subsegment you find.
     28 
     29 Input
     30 
     31 The first line contains integer *n* (1 ≤ *n* ≤ 105). The next line contains *n* integers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109).
     32 
     33 Output
     34 
     35 In a single line print the answer to the problem — the maximum length of the required subsegment.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 6  
     43 7 2 3 1 5 6
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 5
     50 ```
     51 
     52 Note
     53 
     54 You can choose subsegment *a*2, *a*3, *a*4, *a*5, *a*6 and change its 3rd element (that is *a*4) to 4.