Codeforces Round #FF (Div. 2)
又一场中国场,果然注定被虐的场。。。
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)的更多相关文章
- 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] + ...
- Codeforces Round #FF (Div. 1) A. DZY Loves Sequences
题目链接: http://www.codeforces.com/contest/446/problem/A 题解: dp1[x]表示以x结尾的最大严格升序连续串,dp2[x]表示以x开头的最大严格升序 ...
- 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 ...
- Codeforces Round #FF (Div. 2) 题解
比赛链接:http://codeforces.com/contest/447 A. DZY Loves Hash time limit per test 1 second memory limit p ...
- 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 ...
- 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 ...
- Codeforces Round #FF (Div. 2) D. DZY Loves Modification 贪心+优先队列
链接:http://codeforces.com/problemset/problem/447/D 题意:一个n*m的矩阵.能够进行k次操作,每次操作室对某一行或某一列的的数都减p,获得的得分是这一行 ...
- Codeforces Round #FF (Div. 2) C. DZY Loves Sequences
解题报告:输入一个数列,选取一个子数列,要求最多只能改动这个子数列中的一个数,使得这个子数列是严格的升序的(严格升序没有相等的) 我的做法是,第一步把这个 数列的每个升序的子数列都找出来,然后看这些子 ...
- 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 ...
随机推荐
- Delphi CxGrid 汇总(2)
17. 怎样设计多表头的cxGrid? 解决:cxGrid可以解决如下的表头: --------------------------------- | 说明1 | 说明2 | ------------ ...
- asp.net中两款文本编辑器NicEdit和Kindeditor
过Web开发的朋友相信都使用过富文本编辑器,比较出名的CuteEditor和CKEditor很多人应该已经使用过,在功能强大的同时需要加载的东西也变得很多.下面要推荐的两款富文本编辑器都是使用JS编写 ...
- VS活动解决方案平台
测试环境:win7 x64 测试程序:WCF查询数据库后将数据集返回到Winform程序加载并显示 测试结果: 1.从感觉来说Exe在 x86目标平台生成,启动速度快. 2.内存消耗:x86的程序在超 ...
- C#高级功能(四)扩展方法和索引
扩展方法使你能够向现有类型“添加”方法,而无需创建新的派生类型.重新编译或以其他方式修改原始类型. 扩展方法是一种特殊的静态方法,但可以像扩展类型上的实例方法一样进行调用.扩展方法被定义为静态方法,但 ...
- jqueryMobile应用第一课《构建跨平台APP:jQuery Mobile移动应用实战》连载一(Hello World)
有人说每个程序员都曾经有过改变世界的梦想,笔者认为,这与程序员年轻时编写的第一个程序有着莫大的关系.简简单单的一句“hello world”让年轻的心开始相信梦想,用一种低调的壮志凌云向世界展示自己的 ...
- hdu 2645 find the nearest station
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2645 find the nearest station Description Since dande ...
- Windows Phone播放视频流
前言 MediaElement是Windows Phone中播放本地或者网络视频文件和音乐文件的常用控件,支持的格式可以从这里看.通过Play,Pause,Stop,Position方法或属性可以方便 ...
- ubuntu server获取并自动设置最快镜像的方法
一,安装方法1 add-apt-repository ppa:ossug-hychen/getfastmirrorapt-get install getfastmirror 如果添加了临时源,这样移除 ...
- SQL开发技巧(二) 【转】感觉他写的很好
本文转自: http://www.cnblogs.com/marvin/p/DevelopSQLSkill_2.html 本系列文章旨在收集在开发过程中遇到的一些常用的SQL语句,然后整理归档,本系列 ...
- Qt5 程序发布打包
关于qt5在win7下发布 & 打包 ----------------------------------------------------------------------------- ...