PS:这一场真的是上分场,只要手速快就行。然而在自己做的时候不用翻译软件,看题非常吃力非常慢,还有给队友讲D题如何判断的时候又犯了一个毛病,一定要心平气和,比赛也要保证,不要用翻译软件做题;

Codeforces732A

水题;

  1. #include<cstdio>
  2. #include<math.h>
  3. #include<queue>
  4. #include<map>
  5. #include<string>
  6. #include<string.h>
  7. #include<iostream>
  8. #include<algorithm>
  9. using namespace std;
  10. typedef long long LL;
  11. const int INF=0x3f3f3f3f;
  12. const LL mod=1e9+7;
  13.  
  14. int main()
  15. {
  16. int n,m;
  17. scanf("%d%d",&n,&m);
  18. int tmp;
  19. for(int i=0;;i++)
  20. {
  21. tmp=i*10;
  22. if(tmp%n==0&&tmp)
  23. {
  24. printf("%d\n",tmp/n);
  25. return 0;
  26. }
  27. tmp+=m;
  28. if(tmp%n==0)
  29. {
  30. printf("%d\n",tmp/n);
  31. return 0;
  32. }
  33. }
  34. }

Codeforces 732B.
Cormen — The Best Friend Of a Man

求一个最少数量,使得连续两个是>=k

保证b[i]>=a[i];

我肯定是加中间的,加中间的话两边都能利用,而且一定要加;

  1. #include<cstdio>
  2. #include<math.h>
  3. #include<queue>
  4. #include<map>
  5. #include<string>
  6. #include<string.h>
  7. #include<iostream>
  8. #include<algorithm>
  9. using namespace std;
  10. typedef long long LL;
  11. const int INF=0x3f3f3f3f;
  12. const LL mod=1e9+7;
  13. const int N=5e2+10;
  14. int a[N];
  15. int b[N];
  16.  
  17. int main()
  18. {
  19. int n,m;
  20. scanf("%d%d",&n,&m);
  21. for(int i=1;i<=n;i++)
  22. scanf("%d",&a[i]);
  23. int tmp,flag=0,ans=0;
  24. b[1]=a[1];
  25. for(int i=2;i<=n;i++)
  26. {
  27. tmp=b[i-1]+a[i];
  28. if(tmp>=m)
  29. b[i]=a[i];
  30. else
  31. {
  32. b[i]=m-b[i-1];
  33. ans+=b[i]-a[i];
  34. }
  35. }
  36. printf("%d\n",ans);
  37. for(int i=1;i<=n;i++)
  38. {
  39. if(i!=1) printf(" ");
  40. printf("%d",b[i]);
  41. }
  42. return 0;
  43. }

Codeforces 732C
- Sanatorium

最大和最小的数量<=1就一定能全部进行结束,所以求一个最大,保证和最大的差值<=1就好了;

  1. #include<cstdio>
  2. #include<math.h>
  3. #include<queue>
  4. #include<map>
  5. #include<string>
  6. #include<string.h>
  7. #include<iostream>
  8. #include<algorithm>
  9. using namespace std;
  10. typedef __int64 LL;
  11. const int INF=0x3f3f3f3f;
  12. const LL mod=1e9+7;
  13. LL a[4];
  14. int main()
  15. {
  16. LL mx;
  17. scanf("%I64d",&a[1]);
  18. mx=a[1];
  19. for(int i=2;i<=3;i++)
  20. {
  21. scanf("%I64d",&a[i]);
  22. mx=max(a[i],mx);
  23. }
  24. LL ans=0;
  25. for(int i=1;i<=3;i++)
  26. {
  27. if(a[i]+1>=mx)
  28. continue;
  29. ans+=mx-1-a[i];
  30. }
  31. printf("%I64d\n",ans);
  32. return 0;
  33. }

Codeforces 732D

只要二分一个答案,然后判断满不满足就行了,判断的时候倒着判断,开了两个值代表需要准备的天数,已经准备的天数维护一下就好了;

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<string.h>
  4. #include<algorithm>
  5. using namespace std;
  6.  
  7. const int N=1e5+10;
  8. int a[N],w[N];
  9. bool vis[N];
  10. int m;
  11.  
  12. bool Judge(int n)
  13. {
  14. int sum,x,y,num;
  15. memset(vis,false,sizeof(vis));
  16. x=y=num=0;
  17. for(int i=n;i>=1;i--)
  18. {
  19. if(!a[i])
  20. {
  21. if(x>y)
  22. y++;
  23. }
  24. else
  25. {
  26. if(vis[a[i]])
  27. {
  28. if(x>y)
  29. y++;
  30. }
  31. else
  32. {
  33. num++;
  34. x+=w[a[i]];
  35. vis[a[i]]=true;
  36. }
  37. }
  38. if(x==y&&num==m)
  39. return true;
  40. }
  41. return false;
  42. }
  43.  
  44. int solve(int n)
  45. {
  46. int left=1,right=n;
  47. while(left<right)
  48. {
  49. int mid=left+(right-left)/2;
  50. if(Judge(mid))
  51. right=mid;
  52. else
  53. left=mid+1;
  54. }
  55. return left;
  56. }
  57.  
  58. int main()
  59. {
  60. int n;
  61. scanf("%d%d",&n,&m);
  62. for(int i=1;i<=n;i++)
  63. scanf("%d",&a[i]);
  64. for(int i=1;i<=m;i++)
  65. scanf("%d",&w[i]);
  66. if(!Judge(n))
  67. {
  68. puts("-1");
  69. return 0;
  70. }
  71. int ans;
  72. ans=solve(n);
  73. printf("%d\n",ans);
  74. return 0;
  75. }

Codeforces Round #377 (Div. 2)A,B,C,D【二分】的更多相关文章

  1. Codeforces Round #377 (Div. 2) D. Exams

    Codeforces Round #377 (Div. 2) D. Exams    题意:给你n个考试科目编号1~n以及他们所需要的复习时间ai;(复习时间不一定要连续的,可以分开,只要复习够ai天 ...

  2. Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点

    // Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...

  3. Codeforces Round #377 (Div. 2)

    #include <iostream> #include <stdio.h> #include <string.h> using namespace std; in ...

  4. Codeforces Round #377 (Div. 2)D(二分)

    题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i ...

  5. Codeforces Round #377 (Div. 2) E. Sockets

    http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行. 如果不同,还 ...

  6. Codeforces Round #377 (Div. 2) D. Exams 贪心 + 简单模拟

    http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来 ...

  7. Codeforces Round #377 (Div. 2) 被坑了

    http://codeforces.com/contest/732/problem/B 题目要求任意两个连续的日子都要 >= k 那么如果a[1] + a[2] < k,就要把a[2]加上 ...

  8. Codeforces Round #377 (Div. 2) B. Cormen — The Best Friend Of a Man(贪心)

     传送门 Description Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has ...

  9. Codeforces Round #377 (Div. 2) D. Exams(二分答案)

    D. Exams Problem Description: Vasiliy has an exam period which will continue for n days. He has to p ...

随机推荐

  1. linux的su和sudo(转载)

    来源:http://www.jb51.net/LINUXjishu/12713.html 一. 使用 su 命令临时切换用户身份 1.su 的适用条件和威力 su命令就是切换用户的工具,怎么理解呢?比 ...

  2. 自译Solr in action中文版

    文件夹 Part 1 初识 SOLR 1 Solr 简单介绍 2 開始熟悉 Solr 3 Solr 核心概念 4 配置 Solr 5 建立索引 6 文本分析 Part 2 Solr 核心功能 7 发起 ...

  3. 解决对象不支持“getElementsByClassName”属性或方法 ie兼容性

      解决 IE 或者兼容模式不支持 document.getElementsByClassName() 的方法 自已实现document.getElementsByClassName():   网页错 ...

  4. c#4.5新语法--自动属性和隐式类型

    1.自动属性    自动属性是c#中属性定义的两种形式的一种:传统属性定义.自动属性.    1.1 传统属性定义        private int _age;        public int ...

  5. Qt笔记之使用设计器自定义窗口标题栏

    1.在窗口显示之前,设置WindowFlags为FramelessWindowHint,以产生一个没有边界的窗口 例如 Widget::Widget(QWidget *parent) : QWidge ...

  6. s1考试 图书管理系统 结构体版

    #include <iostream> #include <string> #include <cstdio> #include <cstdlib> # ...

  7. Mongoose学习(3)--设置环境变量

    比如我一套代码数据库代码分为中文站和英文站,每个表中我都有一个site_code字段来区分, 两个站点部署在不同的人服务器,这个时候我们就用系统环境变量来区分, 下面直接在mac下设置环境变量 vim ...

  8. assign,copy,strong,weak,nonatomic的具体理解

    例子: NSString *houseOfMM = [[NSString alloc] initWithString:'MM的三室两厅']; 上面一段代码会执行以下两个动作:  1 在堆上分配一段内存 ...

  9. 浅淡!important对CSS的重要性

    SS中的!important是一个非常重要的属性,有时候发挥着非常大的作用,52CSS.com这方面的知识并不是非常多,我们看下面的文章,对它作比较感观的了解. 前几天写一些CSS代码的时候又难为我了 ...

  10. LR添加Windows和Linux压力机实战

    添加Windows和Linux压力机实战 既然Controller是LoadRunner的“心脏”,那么压力产生也必然是它发起的,通过压力机来对被测系统产生压力.一般压力机分为Windows和Linu ...