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. html中设置透明遮罩层的兼容性代码

    说明:下面遮罩层的height视实际情况自行修改,要求显示的div层的样式需加上position:relative,位于遮罩层层div的下面一行.<div id="ceng" ...

  2. EasyCamera Android安卓移动视频监控单兵设备接入EasyDarwin开源流媒体云平台

    前言 随着Android系统的不断更新和发展,现在越来越多的硬件产品选择用安卓系统作为运行环境,电视机,机顶盒.门禁.行车记录仪.车载系统.单兵设备等等,Android系统底层还是Linux,但对上层 ...

  3. 工作室成员 GitHub 地址集中贴(按发布时间先后排序)

    金质行 https://github.com/jinxiaohang/ 金林超 https://github.com/jinlinchao/ 王贤国 https://github.com/ErhuoH ...

  4. java之异常的捕获及处理

    在java中程序的错误主要是语法错误和语义错误(也就是逻辑错误). java中异常处理语句的格式: try{ //有可能出现异常的语句 }catch(异常类 异常对象){ //编写异常的处理语句 }c ...

  5. 13.JavaScript 类

    JavaScript 类 JavaScript 是面向对象的语言,但 JavaScript 不使用类. 在 JavaScript 中,不会创建类,也不会通过类来创建对象(就像在其他面向对象的语言中那样 ...

  6. AndroidDragAndDrop.java

    以下代码使用ApiDemos-debug.apk进行测试 package com.saucelabs.appium; import io.appium.java_client.AppiumDriver ...

  7. bzoj4486: [Jsoi2015]串分割

    肉丝哥哥钦定好题 话说我的blog现在为什么到处都是肉丝哥哥 先来想一个弱化版,假如能够n整除K怎么做? 把每个数字看成一个字符串,按字典序排名,这个可以后缀数组解决,然后暴力枚举每种情况,O(1)判 ...

  8. Android图片加载神器之Fresco-加载图片基础[详细图解Fresco的使用](秒杀imageloader)

    Fresco简单的使用—SimpleDraweeView 百学须先立志—学前须知: 在我们平时加载图片(不管是下载还是加载本地图片…..)的时候,我们经常会遇到这样一个需求,那就是当图片正在加载时应该 ...

  9. ORA-03113: end-of-file on communication channel (通信通道的文件结尾)

    今天有现场反应:数据库连不上了,提示什么归档日志有问题:又问了现场有做过什么特别操作,答曰没有,出问题后,只是重启了操作系统. 现场环境oracle11.0.2.3. 于是远程查看数据库状态,发现数据 ...

  10. 在线判题系统hustoj的搭建

    摘要:ACM/ICPC程序设计竞赛,越来越受到各个高校的重视,是程序设计竞赛中的奥林匹克.Hustoj是搭建在linux系统上的判题系统.能够判断代码的正确性.会及时返回通过或者不通过,如果不通过会返 ...