A. Mountain scenery

Source: Internet
Author: User
Tags polyline
Time limit per test

2 seconds

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

Little Bolek has found a picture N Mountain peaks painted on it. N Painted
Peaks are represented by a non-closed polyline, consisting 2N Segments. The segments go through2NLimit + limit 1 Points
With coordinates (1, bytes,Y1) , (2, bytes,Y2) , ... ,(2NLatency + latency 1, latency,Y2NLimit + limit 1) ,
With I -Th segment connecting the point (I, Bytes,YI) And
The point(ILatency + latency 1, latency,YILimit + limit 1) .
For any even I (2 cores ≤ CoresILimit ≤ limit 2N) The
Following condition holds:YIAccept-limit 1Latency <latencyYI And YILatency> latencyYILimit + limit 1 .

We shall call a vertex of A polyline with an evenXCoordinateMountain Peak.

The figure to
Left shows the initial picture, the figure to the right shows what the picture looks like after Bolek's actions. The affected peaks are marked red, K=
2.

Bolek fancied a little mischief. He chose exactly K Mountain peaks, rubbed out the segments that went through those peaks and increased each
Peak's height by one (that is, He increased Y Coordinate of the corresponding points). Then he painted the missing segments to get
New picture of mountain peaks. Let us denote the points through which the new polyline passes on Bolek's new picture(1, bytes,R1) , (2, bytes,R2) , ... ,(2NLatency + latency 1, latency,R2NLimit + limit 1) .

Given Bolek's final picture, restore the initial one.

Input

The first line contains two space-separated Integers N And K (1 digit ≤ DigitKLimit ≤ limitNLimit ≤0000100) .
The next line contains 2NLimit + limit 1 Space-separated IntegersR1, Bytes,R2, Please..., please ,...,R2NLimit + limit 1 (0 bytes ≤ bytesRILimit ≤0000100) -
TheY Coordinates of the polyline vertices on Bolek's picture.

It is guaranteed that we can obtain the given picture after discovery the described actions on some picture of mountain peaks.

Output

Print 2NLimit + limit 1 IntegersY1, Bytes,Y2, Please..., please ,...,Y2NLimit + limit 1 -
The Y Coordinates of the vertices of the polyline on the initial picture. If there are multiple answers, output any one of them.

Sample test (s) Input
3 20 5 3 5 1 5 2
Output
 
0 5 3 4 1 4 2
Input
1 10 2 0
Output
 
0 1 0

Solution Description: Find a mountain that is 1 or higher than the two valleys next to it, and the output can be reduced by 1. Only output the first K matching mountain heights-1. Note that the mountain points must be in the odd position, and the even part is in the valley. You need to add a judgment.

 # include 
  
    # include 
   
     # include 
    
      # include 
     
       # include 
      
        # include 
       
         # include 
        
          # include 
         
           using namespace STD; int main () {int A [300], n, k, I; scanf ("% d", & N, & K ); N = 2 * n + 1; for (I = 0; I 
          
            A [I-1] + 1 & A [I]> A [I + 1] + 1 & K> 0) {A [I] --; k -- ;}} printf ("% d", a [I]);} printf ("\ n") ;}
          
         
        
       
      
     
    
   
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.