又一场中国场,果然注定被虐的场。。。

A,B:都很水,差不多模拟就好了;

C题:CF难得的题意简洁,

我们可以预处理出从左到右递增的数列个数,

举个例子:1 3 2 4 5 7

L[I]        从左开始   1 2 1 2 3 4

从右往左是递减的个数: R[I]         2 1 1 3 2 1

我们发现对于i: A[I-1]<A[I+1]-1 才有可能改变A[I]找到更多的数,

ANS=MAX(ANS,MAX(L[I-1],R[I+1])+1);

具体有很多被HACK的细节,耐心处理下

代码:

#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#define N 111111
using namespace std; int a[N],l[N],r[N];
int main()
{
int n;
cin>>n;
for (int i=;i<=n;i++){
cin>>a[i];
l[i]=r[i]=;
}
int ans=;
for (int i=;i<=n;i++)
{
if (a[i]>a[i-]) l[i]+=l[i-];
ans=max(ans,l[i]);
} for (int i=n-;i>=;i--)
if (a[i]<a[i+]) r[i]+=r[i+]; l[]=-;
r[n+]=-;
a[]=;
a[n+]=-;
for(int i=;i<=n;i++)
{
if (a[i-]<a[i+]-) ans=max(ans,l[i-]+r[i+]+);
else ans=max(ans,max(r[i+],l[i-])+);
} cout<<ans<<endl;
return ;
}

补充D题:

我们预先统计每行,每列的和,

假如,我们选出了X行(K-X)列,那么ANS还需要减去X*(K-X)*P,好好体会这个方程式。。

然后构造优先堆,每次去最大,求出行拿1-K次,列拿1-K次,

其实代码可以看到思路

CODE:

#include<stdio.h>
#include<queue>
#include<math.h>
#include<string.h>
using namespace std;
typedef long long ll;
priority_queue<ll> Q;
ll r[],c[],f[],g[];
int n,m,k,p;
int main()
{
scanf("%d%d%d%d",&n,&m,&k,&p);
for (int i=;i<=n;i++)
for (int j=;j<=m;j++)
{
int z;
scanf("%d",&z);
r[j]+=z;
c[i]+=z;
} while (!Q.empty()) Q.pop();
for (int i=;i<=n;i++) Q.push(c[i]);
for (int i=;i<=k;i++)
{
int t=Q.top();
Q.pop();
f[i]=f[i-]+t;
Q.push(t-m*p);
} while (!Q.empty()) Q.pop();
for (int i=;i<=m;i++) Q.push(r[i]);
for (int i=;i<=k;i++)
{
int t=Q.top();
Q.pop();
g[i]=g[i-]+t;
Q.push(t-n*p);
} ll ans=-123456789101112334ll;
for (int i=;i<=k;i++)
ans=max(ans,f[i]+g[k-i]-(ll) p*(ll)i*(ll)(k-i));
printf("%I64d\n",ans);
return ;
}

Codeforces Round #FF (Div. 2)的更多相关文章

  1. DP Codeforces Round #FF (Div. 1) A. DZY Loves Sequences

    题目传送门 /* DP:先用l,r数组记录前缀后缀上升长度,最大值会在三种情况中产生: 1. a[i-1] + 1 < a[i+1],可以改a[i],那么值为l[i-1] + r[i+1] + ...

  2. Codeforces Round #FF (Div. 1) A. DZY Loves Sequences

    题目链接: http://www.codeforces.com/contest/446/problem/A 题解: dp1[x]表示以x结尾的最大严格升序连续串,dp2[x]表示以x开头的最大严格升序 ...

  3. Codeforces Round #FF (Div. 2)__E. DZY Loves Fibonacci Numbers (CF447) 线段树

    http://codeforces.com/contest/447/problem/E 题意: 给定一个数组, m次操作, 1 l r 表示区间修改, 每次 a[i] +  Fibonacci[i-l ...

  4. Codeforces Round #FF (Div. 2) 题解

    比赛链接:http://codeforces.com/contest/447 A. DZY Loves Hash time limit per test 1 second memory limit p ...

  5. Codeforces Round #FF (Div. 1) B. DZY Loves Modification 优先队列

    B. DZY Loves Modification 题目连接: http://www.codeforces.com/contest/446/problem/B Description As we kn ...

  6. Codeforces Round #FF (Div. 1) A. DZY Loves Sequences 动态规划

    A. DZY Loves Sequences 题目连接: http://www.codeforces.com/contest/446/problem/A Description DZY has a s ...

  7. Codeforces Round #FF (Div. 2) D. DZY Loves Modification 贪心+优先队列

    链接:http://codeforces.com/problemset/problem/447/D 题意:一个n*m的矩阵.能够进行k次操作,每次操作室对某一行或某一列的的数都减p,获得的得分是这一行 ...

  8. Codeforces Round #FF (Div. 2) C. DZY Loves Sequences

    解题报告:输入一个数列,选取一个子数列,要求最多只能改动这个子数列中的一个数,使得这个子数列是严格的升序的(严格升序没有相等的) 我的做法是,第一步把这个 数列的每个升序的子数列都找出来,然后看这些子 ...

  9. Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash

    A. DZY Loves Hash time limit per test 1 second memory limit per test 256 megabytes input standard in ...

随机推荐

  1. C-链表的一些基本操作【创建-删除-打印-插入】

    #include <stdio.h> #include <stdlib.h> #include <malloc.h> #define LEN sizeof(stru ...

  2. [笔记]--Oracle 10g在Windows 32位系统使用2G以上内存

    1.修改c:\boot.ini文件 打开boot.ini文件,我的电脑->属性->高级->启动和恢复->编辑,设置在最后一行末尾添加/PAE选项后如下: [boot loade ...

  3. C#判断ip地址是否ping的通

    Ping pingSender = new Ping(); PingReply reply = pingSender.Send("127.0.0.1",120);//第一个参数为i ...

  4. bzoj 1012 [JSOI2008]最大数maxnumber

    原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1012 线段树,单点更新.. #include<algorithm> #incl ...

  5. iOS学习之Object-C语言集合遍历和数组排序

    一.集合遍历      1.集合:OC中提供的容器类,数组,字典,集合.      2.遍历:对集合中元素依次取出的过程叫做遍历. 二.for循环遍历      1.通过for循环的循环变量用作数组元 ...

  6. 用Swift重写公司OC项目(Day1)--程序的AppIcon与LaunchImage如何设置

    公司之前的APP呢经过了两次重写,都是使用OC由本人独立开发的,不过这些东西我都不好意思说是自己写的,真心的一个字:丑!!! 客观原因来说主要是公司要的特别急,而且注重的是功能而非效果,公司的美工之前 ...

  7. HTML5七大优势“逼宫”APP

    HTML5颠覆了PC互联网的格局,优化了移动互联网的体验,接下来几年,HTML5将颠覆原生App世界. 跨平台: 在多屏年代,开发者的痛苦指数非常高,人人都期盼HTML5能扮演救星.多套代码.不同技术 ...

  8. shell 函数

    1 shell函数的定义及其调用 shell函数有两种格式: function name { commands } name() { commands } 其中,name为函数名,commands为函 ...

  9. NPOI导出word,以及对table的一些设置

    参考网址:http://www.aiuxian.com/article/p-1970779.html NPOI版本:2.1.3.1 最终效果图: 代码: /// <summary> /// ...

  10. mysql 任意连接

    例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话. mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDE ...