Codeforces Round #243 (Div. 2) C. Sereja and Swaps
由于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的更多相关文章
- 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 ...
- Codeforces Round #243 (Div. 2) C. Sereja and Swaps(优先队列 暴力)
题目 题意:求任意连续序列的最大值,这个连续序列可以和其他的 值交换k次,求最大值 思路:暴力枚举所有的连续序列.没做对是因为 首先没有认真读题,没看清交换,然后,以为是dp或者贪心 用了一下贪心,各 ...
- Codeforces Round #243 (Div. 2) B. Sereja and Mirroring
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- Codeforces Round #243 (Div. 2) A. Sereja and Mugs
#include <iostream> #include <vector> #include <algorithm> #include <numeric> ...
- Codeforces Round #243 (Div. 2) A~C
题目链接 A. Sereja and Mugs time limit per test:1 secondmemory limit per test:256 megabytesinput:standar ...
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读
http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...
- Codeforces Round #243 (Div. 2)——Sereja and Swaps
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012476429/article/details/24665103 题目链接 题意: 给定一个整数 ...
- Codeforces Round #243 (Div. 2)——Sereja and Table
看这个问题之前,能够先看看这个论文<一类算法复合的方法>,说白了就是分类讨论,可是这个思想非常重要 题目链接 题意: 首先给出联通块的定义:对于相邻(上下和左右)的同样的数字视为一个联通块 ...
- Codeforces Round #243 (Div. 1)——Sereja and Two Sequences
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012476429/article/details/24798219 题目链接 题意:给两个长度分别 ...
随机推荐
- Clr Via C#读书笔记---垃圾回收机制
#1 垃圾回收平台的基本工作原理: 访问一个资源所需的具体步骤: 1)调用IL指令newobj,为代表资源的类型分配内存.在C#中使用new操作符,编译器就会自动生成该指令.2)初始化内存,设置资源的 ...
- 【JAVA多线程中使用的方法】
一.sleep和wait的区别. 1.wait可以指定时间,也可以不指定. 而sleep必须制定. 2.在同步的时候,对于CPU的执行权和以及锁的处理不同. wait:释放执行权,释放锁. sleep ...
- poj 3278:Catch That Cow(简单一维广搜)
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 45648 Accepted: 14310 ...
- Linux發送郵件
1.直接使用shell當編輯器 [root@phburdb1 mail]# mail -s "Hello World" juncai.chen@innolux.comHello j ...
- TCP 连接中断的判断
关于TCP 3次握手,4次分手就不多说了.如何判断TCP连接是否中断是个大问题. 1 TCPKeep-alive 机制 并不是TCP 规范的一部分,实现细节差距大. 2 使用heartbeat 检测 ...
- wp8 入门到精通 启动系统分享照片任务
PhotoChooserTask photoChooserTask = new PhotoChooserTask(); photoChooserTask.Completed += photoChoos ...
- thinkphp调用phpqrcode.php生成二维码
thinkphp3. 把phpqrcode文件夹放在ThinkPHP\Library\Vendor\下面 phpqrcode下载: http://files.cnblogs.com/files/qho ...
- 并发异步处理队列 .NET 4.5+
namespace Test { using System; using System.Threading; using System.Threading.Tasks; using Microshao ...
- Arduino101学习笔记(十一)—— 蓝牙BLE
一.BLE技术简介 第四代蓝牙既包括传统的蓝牙,现在标有"蓝牙经典",和新的低功耗蓝牙(Bluetooth LE,或BLE).低数据速率,低功耗优化. 蓝牙LE广播就像一个社区公告 ...
- 理解flex_对齐
容器属性: 左右对齐方式:justify-content:flex-start/flex-end/center/space-between/space-around; 上下对齐方式:align-ite ...