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

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的细节,耐心处理下

代码:

  1. #include<iostream>
  2. #include<string>
  3. #include<string.h>
  4. #include<math.h>
  5. #include<algorithm>
  6. #include<vector>
  7. #include<set>
  8. #include<map>
  9. #define N 111111
  10. using namespace std;
  11.  
  12. int a[N],l[N],r[N];
  13. int main()
  14. {
  15. int n;
  16. cin>>n;
  17. for (int i=;i<=n;i++){
  18. cin>>a[i];
  19. l[i]=r[i]=;
  20. }
  21. int ans=;
  22. for (int i=;i<=n;i++)
  23. {
  24. if (a[i]>a[i-]) l[i]+=l[i-];
  25. ans=max(ans,l[i]);
  26. }
  27.  
  28. for (int i=n-;i>=;i--)
  29. if (a[i]<a[i+]) r[i]+=r[i+];
  30.  
  31. l[]=-;
  32. r[n+]=-;
  33. a[]=;
  34. a[n+]=-;
  35. for(int i=;i<=n;i++)
  36. {
  37. if (a[i-]<a[i+]-) ans=max(ans,l[i-]+r[i+]+);
  38. else ans=max(ans,max(r[i+],l[i-])+);
  39. }
  40.  
  41. cout<<ans<<endl;
  42. return ;
  43. }

补充D题:

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

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

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

其实代码可以看到思路

CODE:

  1. #include<stdio.h>
  2. #include<queue>
  3. #include<math.h>
  4. #include<string.h>
  5. using namespace std;
  6. typedef long long ll;
  7. priority_queue<ll> Q;
  8. ll r[],c[],f[],g[];
  9. int n,m,k,p;
  10. int main()
  11. {
  12. scanf("%d%d%d%d",&n,&m,&k,&p);
  13. for (int i=;i<=n;i++)
  14. for (int j=;j<=m;j++)
  15. {
  16. int z;
  17. scanf("%d",&z);
  18. r[j]+=z;
  19. c[i]+=z;
  20. }
  21.  
  22. while (!Q.empty()) Q.pop();
  23. for (int i=;i<=n;i++) Q.push(c[i]);
  24. for (int i=;i<=k;i++)
  25. {
  26. int t=Q.top();
  27. Q.pop();
  28. f[i]=f[i-]+t;
  29. Q.push(t-m*p);
  30. }
  31.  
  32. while (!Q.empty()) Q.pop();
  33. for (int i=;i<=m;i++) Q.push(r[i]);
  34. for (int i=;i<=k;i++)
  35. {
  36. int t=Q.top();
  37. Q.pop();
  38. g[i]=g[i-]+t;
  39. Q.push(t-n*p);
  40. }
  41.  
  42. ll ans=-123456789101112334ll;
  43. for (int i=;i<=k;i++)
  44. ans=max(ans,f[i]+g[k-i]-(ll) p*(ll)i*(ll)(k-i));
  45. printf("%I64d\n",ans);
  46. return ;
  47. }

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. Oracle Study Note : Users and Basic Security

    1. view the default user account SQL> select username from dba_users; 2. lock all users and set t ...

  2. C# WinForm自定义控件响应键盘事件

    自己定义的winform控件,用其他键盘事件都无法响应,只有用ProcessCmdKey事件可以达到目的(别忘了主窗体的KeyPreview属性要设置为true),写法如下:         prot ...

  3. db2建立表空间

    --缓冲池 CREATE BUFFERPOOL EMP_BUF_POOL  IMMEDIATE  ALL DBPARTITIONNUMS  SIZE 250  NUMBLOCKPAGES 0  PAG ...

  4. hdu 5349 MZL's simple problem

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5349 MZL's simple problem Description A simple proble ...

  5. poj 1459 Power Network

    题目连接 http://poj.org/problem?id=1459 Power Network Description A power network consists of nodes (pow ...

  6. HMMPfam的安装使用手记(转载)

    转载至:http://blog.sina.com.cn/s/blog_3f6403290100rb61.html(感谢原文作者) HMMPfam的安装使用手记前言 简要介绍一下 HMMPfam吧.这还 ...

  7. 58.xilinx原语DCM,PLL的使用

    DCM_BASE 基本数字时钟管理模块的缩写,是相伴和频率可配置的数字锁相环电路,常用于FPGA系统中复杂的时钟管理.如需要频率和相位动态配置,则可以选用DCM_ADV原语,如需要相位动态偏移,可使用 ...

  8. 按键精灵实现自动退出的MsgBox消息框

    要实现自动倒计时退出的消息框,代码如下: Set wsh = CreateObject("WScript.Shell") wsh.popup "设置完毕,3秒后自动退出! ...

  9. NSString+NSStringForJava.m

    // // NSString+NSStringForJava.m // NSStringCategory // // Created by Ryan Tang on 12-10-17. // Copy ...

  10. ostream类重载的operator<<()函数

    ostream类重载了operator<<()以识别不同的类型,如: int short  long unsigned int unsigned short unsigned long f ...