Codeforces Round #243 (Div. 1) A题
http://codeforces.com/contest/425/problem/A 题目链接;
然后拿出这道题目是很多人不会分析题目,被题目吓坏了,其中包括我自己,想出复杂度,一下就出了啊!真是弱!
直接暴力求出矩阵数值,然后枚举每一个【I,J];再O[N]判断,分配好在[I,J]区间的数和之内的数,再排序下SOLO了
CODE:#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include<iostream>
#include<algorithm>
using namespace std;
int a[],b[];
int x[],y[];
int mp[][];
int n,m;
int cmp(int x,int y)
{
return x>y;
}
int main()
{
cin>>n>>m;
int ma=-;
for (int i=;i<=n;i++){
cin>>a[i];
ma=max(ma,a[i]);
}
if (ma<=) {cout<<ma<<endl;return ;}
int o,p;
for (int i=;i<=n;i++)
for (int j=i;j<=n;j++)
{
for (int k=i;k<=j;k++)
mp[i][j]+=a[k];
o=p=;
int t=mp[i][j];
for (int k=;k<=n;k++){
if (k>=i&&k<=j)
x[++o]=a[k];
else y[++p]=a[k];
}
sort(x+,x+o+);
sort(y+,y+p+,cmp);
o=min(o,p);
o=min(o,m);
for (int k=;k<=o;k++)
if (y[k]>x[k])
t=t-x[k]+y[k];
ma=max(ma,t);
}
cout<<ma<<endl;
return ;
}
Codeforces Round #243 (Div. 1) A题的更多相关文章
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #713 (Div. 3)AB题
Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...
- Codeforces Round #552 (Div. 3) A题
题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #243 (Div. 2) B(思维模拟题)
http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...
- Codeforces Round #271 (Div. 2) E题 Pillars(线段树维护DP)
题目地址:http://codeforces.com/contest/474/problem/E 第一次遇到这样的用线段树来维护DP的题目.ASC中也遇到过,当时也非常自然的想到了线段树维护DP,可是 ...
- Codeforces Round #425 (Div. 2))——A题&&B题&&D题
A. Sasha and Sticks 题目链接:http://codeforces.com/contest/832/problem/A 题目意思:n个棍,双方每次取k个,取得多次数的人获胜,Sash ...
- Codeforces Round #579 (Div. 3) 套题 题解
A. Circle of Students 题目:https://codeforces.com/contest/1203/problem/A 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...
随机推荐
- Tomcat工作原理
http://www.cnblogs.com/shootercheng/p/5838645.html
- rails使用 rake db:migrate 提示 Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue.
首先得特么建立数据库 : rake db:create 实际问题是没有int应该用integer http://www.rubycc.com/column/rails3.2.3/rails.htm
- C# 将汉字转化成拼音
本文来自http://www.cnblogs.com/yazdao/archive/2011/06/04/2072488.html 首先下载Visual Studio International Pa ...
- DB2物化表
DB2物化查询表(MQT)是DB2数据库中一类特殊的表 物化表和视图的区别 物化表是一个查询结果集,视图是一个SQL语句. 以下是一个简单例子(说明物化表) 1.创建表,插入测试数据 ----创建表 ...
- SQLserver中idendity的妙用
假设:现在有产品信息需要入库,要给每个产品按找预定的规则进行编号,编号规则如下: 产品编码:6位产品类型码+1位仓库码+2位年份+5位顺序码(要求从00001开始自增) 6位产品类型码:P00001 ...
- 手动书写小代码-foreach实现机制
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...
- hdu 1277 全文检索
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1277 全文检索 Description 我们大家经常用google检索信息,但是检索信息的程序是很困难 ...
- hdu 2648 Shopping
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2648 纯暴力的方法T_T... 如下: #include<cstdio> #include ...
- windows phone版的一个儿教app
昨天下午看见一个园友写的一篇关于儿教的api,看了也就两三个接口,所以数据处理应该不会太复杂,主要是界面的效果,要求可能比较高.于是我就重新自己写了一个app,实现很简单,花的时间比较多的地方应该是在 ...
- Android里面的命名规范
前前后后接触安卓也有一段时间了,但是对于Android命名规范这块一直没有太注意过.导致有的时候写出来的代码,前后的风格根本不一样,今天在网上查了一下,正好对自己来说可以好好的总结一下. 首先在And ...