Codeforces Round 243 (Div. 1)
A
Sereja and Swaps
Codeforces
1500
原题
←B →
翻译中…

As usual, Sereja has array $*a*$, its elements are integers: $*a*[1], *a*[2], ..., *a*[*n*]$. Let's introduce notation:

翻译中…

image

翻译中…

A swap operation is the following sequence of actions:

翻译中…
  • choose two indexes $*i*, *j*$ $(*i* ≠ *j*)$;
  • perform assignments $*tmp* = *a*[*i*], *a*[*i*] = *a*[*j*], *a*[*j*] = *tmp*$.
翻译中…

What maximum value of function $*m*(*a*)$ can Sereja get if he is allowed to perform at most $*k*$ swap operations?

翻译中…

Input

翻译中…

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)$.

翻译中…

Output

翻译中…

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.

翻译中…

样例

Input #1
10 2
10 -1 2 2 2 2 2 2 -1 10
Output #1
32
InputCopy OutputCopy
Input #2
5 10
-1 -1 -1 -1 -1
Output #2
-1
InputCopy OutputCopy
题目信息
题号
425A
时间限制
1 s
内存限制
256 MB
标签
暴力
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。