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题的更多相关文章

  1. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  2. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  3. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #243 (Div. 2) B(思维模拟题)

    http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...

  7. Codeforces Round #271 (Div. 2) E题 Pillars(线段树维护DP)

    题目地址:http://codeforces.com/contest/474/problem/E 第一次遇到这样的用线段树来维护DP的题目.ASC中也遇到过,当时也非常自然的想到了线段树维护DP,可是 ...

  8. Codeforces Round #425 (Div. 2))——A题&&B题&&D题

    A. Sasha and Sticks 题目链接:http://codeforces.com/contest/832/problem/A 题目意思:n个棍,双方每次取k个,取得多次数的人获胜,Sash ...

  9. Codeforces Round #579 (Div. 3) 套题 题解

    A. Circle of Students      题目:https://codeforces.com/contest/1203/problem/A 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...

随机推荐

  1. C语言-L Buffer is too small && 0 解决方法

    问题如下: 问题出在程序语句(见下): 其中,字符串p1和p2分别指向某个字符串,p是定义的一个字符数组.问题出现在对strlen()的使用,这个函数计算的字符串长度是不包括'\0'的,所以在设置第二 ...

  2. VMware虚拟机升级过程中遇到的一点问题

    在将VWware由9.0升级到10.0的过程中,出现如下图的错误:        failed to create the requested registry key Key:Installer e ...

  3. public void onItemClick(AdapterView arg0, View view, int position,long arg3)详解【整理自网络】

    参考自: http://blog.csdn.net/zwq1457/article/details/8282717 http://blog.iamzsx.me/show.html?id=147001 ...

  4. PHP JS HTML ASP页面跳转代码 延时跳转代码 返回到上一界面并刷新 JS弹出指定大小的新窗口

    1.PHP延时跳转代码 //跳转到浏览界面 header("Refresh:1;url=machine_list.php"); //不延时 <?php header(&quo ...

  5. STM32F0xx_SPI读写(Flash)配置详细过程

    Ⅰ.概述 关于SPI(Serial Peripheral Interface)串行外设接口可以说是单片机或者嵌入式软件开发人员必须掌握的一项通信方式,就是你在面试相关工作的时候都可能会问及这个问题.在 ...

  6. Java学习中,常用的命令管理(Java 学习中的小记录)

    Java学习中,常用的命令管理      作者:王可利(Star·星星) 一.Window中常见的dos命令 在哪里操作dos命令: Win7 ---> 开始  ---->所有程序---& ...

  7. EMVTag系列17《9F66 终端交易属性》

    字节:1 8    1 – 支持非接触磁条 (MSD) 0– 不支持非接触磁条 (MSD) 7    1 – 支持非接触PBOC 0– 不支持非接触PBOC 6    1 – 支持非接触qPBOC 0 ...

  8. oracle 临时表空间

    环境: OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3. ...

  9. C# DateTime详解

    //今天DateTime.Now.Date.ToShortDateString();//昨天,就是今天的日期减一DateTime.Now.AddDays(-1).ToShortDateString() ...

  10. thinkphp用phpexcel读取excel,并修改列中的值,再导出excel,带往excel里写入图片

    <?php class GetpriceAction extends AdministratorAction { // 文件保存路径 protected $savepath; // 允许上传的文 ...