Codeforces Round #243 (Div. 1) A Sereja and Swaps
来源:互联网 发布:手机免费网络电话软件 编辑:程序博客网 时间:2024/06/05 09:11
URL:http://codeforces.com/contest/425/problem/A
题目描述:
题目描述:
A. Sereja and Swaps
time limit per test memory limit per test
1 second 256 megabytesAs usual, Sereja has array a, its elements are integers:a[1],?a[2],?...,?a[n]. Let's introduce notation:
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 mostk swap operations?
Input
The first line contains two integers n andk(1?≤?n?≤?200; 1?≤?k?≤?10). The next line containsn integersa[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 mostk swap operations.
Sample test(s)
Input
10 210 -1 2 2 2 2 2 2 -1 10
Output
32
Input
5 10-1 -1 -1 -1 -1
Output
-1
解题思路:穷举
穷举所有范围内能取得的最大值,对于某一范围,将此范围内的数据单独拿出并排序,再把此范围外的数据存入另一数组并排序,在k次之内,每次拿后者的最大值a替换前者的最小值b(前提是a>b)。
代码:
0 0
- Codeforces Round #243 (Div. 1) A Sereja and Swaps
- Codeforces Round #243 (Div. 2) C. Sereja and Swaps
- Codeforces Round #243 (Div. 2)——Sereja and Swaps
- Codeforces Round #243 (Div. 2) C. Sereja and Swaps
- Codeforces Round #243 (Div. 2)-C. Sereja and Swaps(multiset)
- Codeforces Round #243 (Div. 2) C. Sereja and Swaps 解题报告
- Sereja and Algorithm -----Codeforces Round #215 div.1 A
- Codeforces Round #223 (Div. 1) A - Sereja and Prefixes
- 【瞎搞】 Codeforces Round #215 (Div. 1) A Sereja and Algorithm
- CodeForces 425A Sereja and Swaps
- Codeforces 425A Sereja and Swaps(暴力)
- codeforces 425A Sereja and Swaps
- Codeforces Round #243 (Div. 1) B Sereja and Table
- Codeforces Round #243 (Div. 1)——Sereja and Squares
- Codeforces Round #243 (Div. 1) C Sereja and Two Sequences
- Codeforces Round #215 (Div. 2) -A. Sereja and Coat Rack
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
- Codeforces Round #223 (Div. 2)--A. Sereja and Dima
- android 使用单例还是service?
- 阅读程序1
- hiernate xml 和注释配置 (声明式和显示式)
- 编程思想基本概念
- 程序阅读2
- Codeforces Round #243 (Div. 1) A Sereja and Swaps
- 【蓝桥杯】分糖果(2014预赛java-B7)
- ClientDataSet加上TDataSetProvider的数据保存问题
- 不知道做了什么,电脑好卡。。。讲讲Socket,我不太懂,却开始懂得知识
- 《c++primer(第四版)》习题8.6
- Android学习之 有关图片缓存问提的代码封装<二>
- python获取当前日期
- 《c++primer(第四版)》习题8.7
- MVC3.0下使用百度富文本编辑器UMEditor1.2.2上传图片