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 ...
随机推荐
- CSS 设置TABLE 表格 边框
/*table列表 合并边框设置*/ .tablelist { border-collapse:collapse; } /*table列表 设置边框宽度及颜色*/ .tablelist td { bo ...
- How to display SSRS report based on customer/Vendor specific language [AX2012]
Common requirement is to show the reports in customer’s language. [example : Quotations, sales confi ...
- 金山词霸每日一句开放平台 .NET demo
先附上地址:http://open.iciba.com/?c=api 小金山提供了2种获取数据的方式 1. 通过填入自己的网站名称.网址.邮箱地址 来生成一段javascript脚本,直接将生成的代码 ...
- List GetEnumerator
static void Main() { List<int> list = new List<int>(); list.Add(); list.Add(); list.Add( ...
- [terry笔记]RMAN综合学习之备份
rman是最经济实惠的oracle备份工具,在这里做一个rman的整体学习. 文章中大多是rman命令的语法,还是最好做做实验,以便印象深刻,因为大多数数据库的备份就是按时跑脚本,恢复也不是经常能遇到 ...
- [terry笔记]IMPDP报错ORA-39083 Object type TYPE failed to create ORA-02304
今天在使用impdp导入的时候(同一数据库中转换schema),遇到了 ORA-39083: Object type TYPE failed to create with error: ORA-023 ...
- 说说用C语言求根的那些事儿
C语言--求根:计算机只识别0和1,那么问题来了,作为计算工具如何解决数学问题?其实,计算机是死东西,都是程序员用计算机的的思维去加数学公式计算数学题的.听起来好高端的样子,其实啊,也就那么回事儿, ...
- ED/EP系列3《基本指令》
Ø --APPLICATIONBLOCK(应用锁定): Ø --APPLICATION UNBLOCK(应用解锁): Ø --CARDBLOCK(卡片锁定): Ø --EXTERNAL AUTHENT ...
- Tomcat 服务器服务的注册修改删除
1. 注册Tomcat服务 运行cmd,切换目录到tomcat/bin, 执行以下命令service.bat install 2.删除Tomcat服务
- Android-----第三方 ImageLoader 的简单配置和使用
ImageLoader 的简单使用配置,最好是将配置信息放到application里面,这样我们就不需要每次使用都需要配置了 1.首先我们得有一个包 2.简单的配置信息 //显示图片的配置 Displ ...