codeforces-scrape

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

425A.md (1196B)


      1 Source: https://codeforces.com/problemset/problem/425/A
      2 
      3 A. Sereja and Swaps
      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 As usual, Sereja has array *a*, its elements are integers: *a*[1], *a*[2], ..., *a*[*n*]. Let's introduce notation:
     22 
     23 ![](https://espresso.codeforces.com/eeff175d11496a6af7bbd528a58e3e5c10fdf69d.png)
     24 
     25 A swap operation is the following sequence of actions:
     26 
     27 * choose two indexes *i*, *j* (*i* ≠ *j*);
     28 * perform assignments *tmp* = *a*[*i*], *a*[*i*] = *a*[*j*], *a*[*j*] = *tmp*.
     29 
     30 What maximum value of function *m*(*a*) can Sereja get if he is allowed to perform at most *k* swap operations?
     31 
     32 Input
     33 
     34 The first line contains two integers *n* and *k* (1 ≤ *n* ≤ 200; 1 ≤ *k* ≤ 10). The next line contains *n* integers *a*[1], *a*[2], ..., *a*[*n*] ( - 1000 ≤ *a*[*i*] ≤ 1000).
     35 
     36 Output
     37 
     38 In a single line print the maximum value of *m*(*a*) that Sereja can get if he is allowed to perform at most *k* swap operations.
     39 
     40 Examples
     41 
     42 Input
     43 
     44 ```
     45 10 2  
     46 10 -1 2 2 2 2 2 2 -1 10
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 32
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 5 10  
     59 -1 -1 -1 -1 -1
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 -1
     66 ```