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 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...
随机推荐
- C# 文件流基本操作步骤
private void button1_Click(object sender, EventArgs e) { FileStream fs = new FileStream("123.tx ...
- 异步导出excel
最近看园里有几篇写有关导出导入excel的博客,我正好最近在项目中也有涉及想来一起分享一下,正好整理一下自己的思路. 一.异步的方式是通过iframe来实现,代码如下: if ($('#downloa ...
- 在一般处理程序中,把Form Post过来的表单集合转换成对象 ,仿 MVC post,反射原理
using System; using System.Collections.Generic; using System.Collections.Specialized; using System.L ...
- 第十四章 调试及安全性(In .net4.5) 之 对称及非对称加密
1. 概述 本章内容包括:对称及非对称加密算法..net中的加密类.使用哈希操作.创建和管理签名认证.代码访问权限 和 加密字符串. 2. 主要内容 2.1 使用对称和非对称加密 ① 对称加密:使用同 ...
- book publisher and study
http://www.apress.com/ https://pragprog.com/ https://www.packtpub.com/ http://www.howzhi.com/
- LaTeX让公式跟随章节编号
正常公式编号会是(1)(2)这种,想要编号成(3.1) (3.2)怎么办呢? \usepackage{amsmath} \numberwithin{equation}{section} 在导言区加入以 ...
- WPF中线性渐变画刷的一个小窍门
最近被项目里面控件的设计搞的死去活来的,大部分的设计都会需要使用进度条的功能,因为UI形状的变态,使用ProgressBar不能满足需求,没办法就自己想办法实现进度显示.折腾的多了发现一个很不错的方法 ...
- C 构造一个 简单配置文件读取库
前言 最近看到这篇文章, json引擎性能对比报告 http://www.oschina.net/news/61942/cpp-json-compare?utm_source=tuicool 感觉技术 ...
- php之常用函数库
1.时间和日期 如何获取时间戳 time()--从1970年开始计算的毫秒数 echo time(); 日期 echo date('Y-m-d H:i:s'); 获取默认是时区 echo date_d ...
- mac 系统开发android,真机调试解决方案
1.确保你的android设备真正链接到电脑上了,我在这里遇到过坑,弄了好久,才发现能充电的线,确无法传递数据过去.所以不要以为随便拿一根线,能充电,就可以传递数据了,我就是这么傻傻的拿了根不能用的数 ...