由于n比较小,直接暴力解决

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include<iterator>
using namespace std; int main(){
int n,k;
cin >> n >> k;
vector<int> a(n);
for(int i = ; i < n; ++ i) cin >> a[i];
int sum = accumulate(a.begin(),a.end(),);
for(int i = ; i < n; ++ i){
for(int j = i ; j < n ; ++ j ){
vector<int> tmp(a.begin()+i,a.begin()+j+);
sort(tmp.begin(),tmp.end());
if(j-i+!=n){
vector<int> b(a);
b.erase(b.begin()+i,b.begin()+j+);
sort(b.begin(),b.end(),greater<int>());
for(int x =, y = ; b[x]>tmp[y] && x < k && x < b.size(); ++x ,++y){
tmp[y] = b[x];
}
}
sum = max(sum,accumulate(tmp.begin(),tmp.end(),));
}
}
cout<<sum<<endl;
}

Codeforces Round #243 (Div. 2) C. Sereja and Swaps的更多相关文章

  1. Codeforces Round #243 (Div. 1)A. Sereja and Swaps 暴力

    A. Sereja and Swaps time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #243 (Div. 2) C. Sereja and Swaps(优先队列 暴力)

    题目 题意:求任意连续序列的最大值,这个连续序列可以和其他的 值交换k次,求最大值 思路:暴力枚举所有的连续序列.没做对是因为 首先没有认真读题,没看清交换,然后,以为是dp或者贪心 用了一下贪心,各 ...

  3. Codeforces Round #243 (Div. 2) B. Sereja and Mirroring

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

  4. Codeforces Round #243 (Div. 2) A. Sereja and Mugs

    #include <iostream> #include <vector> #include <algorithm> #include <numeric> ...

  5. Codeforces Round #243 (Div. 2) A~C

    题目链接 A. Sereja and Mugs time limit per test:1 secondmemory limit per test:256 megabytesinput:standar ...

  6. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  7. Codeforces Round #243 (Div. 2)——Sereja and Swaps

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012476429/article/details/24665103 题目链接 题意: 给定一个整数 ...

  8. Codeforces Round #243 (Div. 2)——Sereja and Table

    看这个问题之前,能够先看看这个论文<一类算法复合的方法>,说白了就是分类讨论,可是这个思想非常重要 题目链接 题意: 首先给出联通块的定义:对于相邻(上下和左右)的同样的数字视为一个联通块 ...

  9. Codeforces Round #243 (Div. 1)——Sereja and Two Sequences

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012476429/article/details/24798219 题目链接 题意:给两个长度分别 ...

随机推荐

  1. 数据结构和算法 – 4.字符串、 String 类和 StringBuilder 类

    4.1.String类的应用 class String类应用 { static void Main(string[] args) { string astring = "Now is The ...

  2. Delphi面向对象的方法

    方法是属于一个给定对象的过程和函数,方法反映的是对象的行为而不是数据,前一篇提到的对象的两个重要的方法:构造方法和析构方法. 为了使对象能执行各种功能,你能在对象中定制方法 创建一个方法用两个步骤,首 ...

  3. 无废话ExtJs 入门教程十二[下拉列表联动:Combobox_Two]

    无废话ExtJs 入门教程十二[下拉列表联动:Combobox_Two] extjs技术交流,欢迎加群(201926085) 不管是几级下拉列表的联动实现本质上都是根据某个下拉列表的变化,去动态加载其 ...

  4. UVA 10828 Back to Kernighan-Ritchie(高斯消元)

    高斯消元求概率 对于非起点,期望x[i] = ∑x[j] / deg[j] #include<cstdio> #include<iostream> #include<cs ...

  5. 攻城狮在路上(贰) Spring(一)--- 软件环境、参考书目等一览表

    一.软件环境: 二.参考书目: <Spring 3.X 企业应用开发实战> 陈雄华.林开雄著 电子工业出版社出版 三.其他说明: spring 源码地址:https://github.co ...

  6. PMP 第十一章 项目风险管理

    1规划风险管理 2识别风险 3 风险定性分析 4风险定量分析 5规划风险应对 6监控风险 1.项目风险是什么?已知未知风险.未知未知风险对应应急储备和管理储备的关系.风险承受力和风险偏好是什么? 2. ...

  7. 在IIS上部署SSL

    背景: 在处理DropboxAPI开发时,其重定向的URL地址必须是https的[除了localhost],不得已在自己网站上加了ssl,下面简单介绍下添加自签名证书,毕竟只是临时使用. 1.打开II ...

  8. Effective C++ 之 0 导读(Introduction)

    Effective C++ 导读 (Introduction) 术语(terminology) 声明式 (declaration) 是告诉编译器某个东西的名称和类型(type),但略去细节.以下都是声 ...

  9. C# 指针操作图像 细化处理

    /// <summary> /// 图形细化 /// </summary> /// <param name="srcImg"></para ...

  10. How to use Ajax on Visualforce page on Salesforce platform

    Just use Ajax pattern to call object data from server on visualforce page. Following is the Asynchro ...