由于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. OID View

    http://oid-info.com/get/1.3.6.1.2.1.17.1.4.1.2

  2. WPF样式

    <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winf ...

  3. poj 2262【素数表的应用---判断素数】【哈希】

    Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 35214   Accepted: ...

  4. 最终排名 sdut 2446

    最终排名 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/p ...

  5. 蛋疼的Fedora17

    在公司给同事要安装ASM oracle 11g,说要在forder17上安装,于是乎我先在自己的虚拟机上安装了一个forder17,遇到了几个很蛋疼的问题:      1. 安装的时候没有创建普通用户 ...

  6. Howto: Connect MySQL server using C program API under Linux or UNIX

    From my mailbag: How do I write a C program to connect MySQL database server? MySQL database does su ...

  7. IIS常见错误

    1.IIS7运行时访问报错,先安装VS,再启用的IIS,那么需要为IIS进行注册,在VS工具命令行中执行“aspnet_regiis.exe -ir -enable”即可 2.错误“未能加载文件或程序 ...

  8. C# RFID windows 服务 串口方式

    话说RFID以前很火所以整理一下一年前自己处理的RFID程序,放源码. 一开始觉得他是个很神奇的东西. 包含串口通讯和网络通讯. 由于网络通讯设备太贵,所以国内的设备基本上都是在外置一个比较便宜的模块 ...

  9. 如何控制Java中的线程,总结了3种方法...

    问题:利用Java多线程,轮流打印数字,也就是怎么控制线程.... 1:通过synchronized的关键字,对类的static final 成员进行Lock,锁住对象,来实现同步. private ...

  10. loj 1201(最大独立集)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26913 思路:水题一枚,就是求最大独立集.最大独立集=顶点数-最大 ...