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. Delphi用TActionList下载文件

    TActionList有个标准动作TDownLoadURL,内部是使用的URLDownloadToFile,它下载文件时会定时产生OnDownloadProgress 事件,这样就可以用进度条显示: ...

  2. Sorl之.net操作

    http://www.cnblogs.com/zhangweizhong/category/771055.html 插入: SolrNet.Startup.Init<Movie>(&quo ...

  3. WCF中使用控件的委托,线程中的UI委托

    UI界面: <Window x:Class="InheritDemo.Window1" xmlns="http://schemas.microsoft.com/wi ...

  4. 第十九章 数据访问(In .net4.5) 之 处理数据

    1. 概述 本章介绍 数据库.Json和Xml.web services 三种介质上的数据操作. 2. 主要内容 2.1 数据库 ① 建立连接 .net平台中的数据连接类都继承自DbConnectio ...

  5. python datetime date time详解

    之前一直被datetime,date,time弄的有点乱,可能是因为看文档每太看明白,找到了两篇文章供大家阅读都是转载的,其中有些名词这里解释一下: 世界协调时间(Universal Time Coo ...

  6. Linux下自带的regex

    Linux下可直接用regex.h来支持正则表达式. Android同样也有该头文件,可认为Android也是支持的. #include <sys/types.h> #include &l ...

  7. oracle自定义job名字,job调度

    一.调试创建 begin -- create_schedule dbms_scheduler.create_schedule(schedule_name => 's_change_send_da ...

  8. 微软云平台媒体服务实践系列 1- 使用静态封装为iOS, Android 设备实现点播(VoD)方案

    微软的云平台媒体服务为流媒体服务提供了多种选择,在使用流媒体服务为企业做流媒体方案时,首先需要确认要流媒体接收目标,如针对广大iOS, Android移动设备,由于它们都支持HLS 格式的流媒体,基于 ...

  9. golang的{}初始化

    之前说到Golang中某些类型可以赋值nil, 某些类型不能赋值nil. 不能赋值nil都是initialized value不为nil的类型, 例如: bool int, intN uint, ui ...

  10. Layout Support 获取上下bar的长度

    Layout Support This protocol . You can use layout guides as layout items in the NSLayoutConstraint f ...