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

Codeforces732A

水题;

#include<cstdio>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7; int main()
{
int n,m;
scanf("%d%d",&n,&m);
int tmp;
for(int i=0;;i++)
{
tmp=i*10;
if(tmp%n==0&&tmp)
{
printf("%d\n",tmp/n);
return 0;
}
tmp+=m;
if(tmp%n==0)
{
printf("%d\n",tmp/n);
return 0;
}
}
}

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

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

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

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

#include<cstdio>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
const int N=5e2+10;
int a[N];
int b[N]; int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
int tmp,flag=0,ans=0;
b[1]=a[1];
for(int i=2;i<=n;i++)
{
tmp=b[i-1]+a[i];
if(tmp>=m)
b[i]=a[i];
else
{
b[i]=m-b[i-1];
ans+=b[i]-a[i];
}
}
printf("%d\n",ans);
for(int i=1;i<=n;i++)
{
if(i!=1) printf(" ");
printf("%d",b[i]);
}
return 0;
}

Codeforces 732C
- Sanatorium

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

#include<cstdio>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef __int64 LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
LL a[4];
int main()
{
LL mx;
scanf("%I64d",&a[1]);
mx=a[1];
for(int i=2;i<=3;i++)
{
scanf("%I64d",&a[i]);
mx=max(a[i],mx);
}
LL ans=0;
for(int i=1;i<=3;i++)
{
if(a[i]+1>=mx)
continue;
ans+=mx-1-a[i];
}
printf("%I64d\n",ans);
return 0;
}

Codeforces 732D

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

#include<cstdio>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std; const int N=1e5+10;
int a[N],w[N];
bool vis[N];
int m; bool Judge(int n)
{
int sum,x,y,num;
memset(vis,false,sizeof(vis));
x=y=num=0;
for(int i=n;i>=1;i--)
{
if(!a[i])
{
if(x>y)
y++;
}
else
{
if(vis[a[i]])
{
if(x>y)
y++;
}
else
{
num++;
x+=w[a[i]];
vis[a[i]]=true;
}
}
if(x==y&&num==m)
return true;
}
return false;
} int solve(int n)
{
int left=1,right=n;
while(left<right)
{
int mid=left+(right-left)/2;
if(Judge(mid))
right=mid;
else
left=mid+1;
}
return left;
} int main()
{
int n;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&w[i]);
if(!Judge(n))
{
puts("-1");
return 0;
}
int ans;
ans=solve(n);
printf("%d\n",ans);
return 0;
}

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. C语言宏定义时#(井号)和##(双井号)作用

    #的功能是将其后面的宏参数进行字符串化操作(Stringfication),简单说就是在对它所引用的宏变量 通过替换后在其左右各加上一个双引号. #define example(instr) prin ...

  2. The type List is not generic(转载)

    错误:The type List is not generic; it cannot be parameterized with arguments <Activity> 代码如下: pu ...

  3. EasyDarwin EasyCamera支持海康摄像机接入了

    本文转自EasyDarwin开源团队成员Alex的博客:http://blog.csdn.net/cai6811376/article/details/52709816 EasyCamera默认使用海 ...

  4. EasyDarwin开源流媒体云平台VS调试断点提示“还没有为该文档加载任何符号”的解决办法

    本文转自EasyDarwin开源团队成员Alex的博客:http://blog.csdn.net/cai6811376/article/details/52063666 近日,我们EasyDarwin ...

  5. tornado之运行第一个tornado程序

    Tornado是使用Python编写的一个强大的.可扩展的Web服务器.它在处理严峻的网络流量时表现得足够强健,但却在创建和编写时有着足够的轻量级,并能够被用在大量的应用和工具中. 首先是安装torn ...

  6. MARA 附加结构(增强字段)

  7. spring IOC(转)

    原文 http://stamen.iteye.com/blog/1489223 引述:IoC(控制反转:Inverse of Control)是Spring容器的内核,AOP.声明式事务等功能在此基础 ...

  8. Machine Learning in Action(5) SVM算法

    做机器学习的一定对支持向量机(support vector machine-SVM)颇为熟悉,因为在深度学习出现之前,SVM一直霸占着机器学习老大哥的位子.他的理论很优美,各种变种改进版本也很多,比如 ...

  9. linux jdk更换

    有时候会发现,安装了新的jdk,而java -version 之后发现仍旧是旧的jdk,即使自己已经更新了JAVA_HOME的环境变量,解决方法如下: 具体如下: 1. 查看相应的jdk是否在 ubu ...

  10. 对于atomic nonatomic assign retain copy strong weak的简单理解

    atomic和nonatomic用来决定编译器生成的getter和setter是否为原子操作 1)atomic 设置成员变量的@property属性时,atomic是默认值,提供多线程安全 在多线程环 ...