【Codeforces】Round #491 (Div. 2) 总结


这次尴尬了,D题fst,E没有做出来。。。。

不过还好,rating只掉了30,总体来说比较不稳,下次加油


A:If at first you don’t succeed…




SB题,就是注意一下特判就好了,然后我一开始wa了三次。。。

#include<bits/stdc++.h>
using namespace std;
int read(){
int ans=0,w=1;char c=getchar();
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')c=getchar(),w=-1;
while(isdigit(c))ans=ans*10+c-'0',c=getchar();
return ans*w;
}
int main(){
int a=read(),b=read(),c=read(),d=read();
if(a+b-c>=d||a>d||b>d||c>d||c>a||c>b){
cout<<"-1";
}else cout<<d-a-b+c;
return 0;
}

B:Getting an A



比较稳过的一题

排序,从最小的一位开始贪心

#include<bits/stdc++.h>
using namespace std;
int read(){
int ans=0,w=1;char c=getchar();
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')c=getchar(),w=-1;
while(isdigit(c))ans=ans*10+c-'0',c=getchar();
return ans*w;
}
double a[110];
int n;
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+n+1);
double sum=0;
for(int i=1;i<=n;i++)sum+=a[i];
int ans=0;double minv=4.5*(double)n;
while(sum<minv){
ans++;
sum=sum-a[ans]+5;
}
cout<<ans;
return 0;
}

C:Candies



虽然我也不知道复杂度是什么,但是二分+check可以稳过,只用枚举k然后暴力检查就好,一开始因为二分写挂T了,后面顺利AC

#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL n;
bool check(LL w,LL p){
LL tmp=0,pic=p;
while(pic>0){
if(w>=pic){
tmp+=pic;
return tmp*2>=p;
}
tmp+=w;
pic-=w;
pic-=pic/10;
if(tmp*2>=p)return 1;
}
return 0;
}
void solve(LL p){
LL l=1,r=p,ans=0;
while(l<=r){
LL mid=(l+r)>>1;
if(check(mid,p))r=mid-1,ans=mid;
else l=mid+1;
}
cout<<ans<<endl;
}
int main(){
cin>>n;
solve(n);
return 0;
}

D:Bishwock



DP很裸,就是需要注意一下当有连续三个位置(包含两个字符串)都是空的,可以放进两个

000 -> XX + 0X = XXX

000 -> X0 + XX = XXX

#include<bits/stdc++.h>
using namespace std;
int f[110]={0};
char c[2][110];
int mx[4]={0,0,1,1};
int my[4]={0,1,0,1};
bool check(int pos,int id){
for(int i=0;i<4;i++){
if(i==id)continue;
int nx=pos-mx[i],ny=1-my[i];
if(c[ny][nx]=='X')return 0;
}
return 1;
}
bool emp(int pos){
return c[0][pos]=='0'&&c[1][pos]=='0';
}
int main(){
scanf("%s%s",c[0],c[1]);
int n=strlen(c[0]);
for(int i=1;i<n;i++){
f[i]=f[i-1];
for(int j=0;j<4;j++)
if(check(i,j))f[i]=max(f[i],f[i-2]+1);
if(i>=2&&emp(i)&&emp(i-1)&&emp(i-2))f[i]=max(f[i],f[i-3]+2);
}
cout<<f[n-1];
return 0;
}

E:Bus Number




F:Concise and clear



【Codeforces】Round #491 (Div. 2) 总结的更多相关文章

  1. Codeforces Round #491 (Div. 2)

    Codeforces Round #491 (Div. 2) https://codeforces.com/contest/991 A #include<bits/stdc++.h> us ...

  2. 【Codeforces】Codeforces Round #491 (Div. 2) (Contest 991)

    题目 传送门:QWQ A:A - If at first you don't succeed... 分析: 按照题意模拟 代码: #include <bits/stdc++.h> usin ...

  3. Codeforces Round #491 (Div. 2) E - Bus Number + 反思

    E - Bus Number 最近感觉打CF各种车祸.....感觉要反思一下, 上次读错题,这次想当然地以为18!肯定暴了longlong 而没有去实践, 这个题我看到就感觉是枚举每个数字的个数,但是 ...

  4. Codeforces Round #491 (Div. 2)部分题解

    这场比赛好鬼畜啊,,A题写崩了wa了4遍,心态直接爆炸,本来想弃疗了,结果发现BCD都是傻逼题.. A. If at first you don't succeed...(容斥原理) 题目大意: 有$ ...

  5. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  6. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  7. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  8. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  9. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

随机推荐

  1. C# 操作FTP

    操作FTP管理类: using System; using System.Collections.Generic; using System.Text; using System.Net; using ...

  2. 监控控制台是否运行的bat

    @echo offrem set secs=5set srvname="TRS.Export.Scheduler.exe" echo.echo ================== ...

  3. Enter键禁止表单提交

    Enter键禁止表单提交js代码: //禁用Enter键表单自动提交 document.onkeydown = function (event) { var target, code, tag; if ...

  4. JavaScript设计模式与开发实践:惰性函数

    Web开发中,因为浏览器之间的差异实现差异,一些嗅探工作总是不可避免的,比如我们需要在各个浏览器中能够通用事件绑定函数addEvent //一般写法 //缺点:当他每次被调用的时候都都会执行里面的if ...

  5. spring mvc: 资源绑定视图解析器(不推荐)

    spring mvc: 资源绑定视图解析器(不推荐) 不适合单控制器多方法访问,有知道的兄弟能否告知. 访问地址: http://localhost:8080/guga2/hello/index 项目 ...

  6. oracle 11g安装过程中问题:移动bin\oralbac11.dll 到bin\oralbac11.dll.dbl出错

    解决方法: 直接找到oralbac11.dll.dbl这个文件,将其删除即可.   http://blog.sina.com.cn/s/blog_51beaf0e0101000v.html

  7. 何时使用img标签,何时使用background-image背景图像

    在什么情况下更适合使用HTML IMG标签来显示一个图像,而不是一个CSS有背景图像,反之亦然? 如下场景使用img标签比较合适: 1.如果图像是等内容的一部分或图表或人(真正的人,而不是股票图人), ...

  8. 5分钟弄懂Docker

    尽管之前久闻Docker的大名了,但是天资愚钝,对其到底是个啥东西一直摸不清,最近花了一段时间整理了一下,算是整理出一点头绪来. 官网的介绍是这样的: Docker is an open platfo ...

  9. Java中子类对象赋值给父类变量

    1. 在Java中将一个字类对象赋值给父类变量是合法的,这也是实现多态(即方法的动态分派)的前提条件之一. 2. 在Java中父类赋值同样也适用于数组.可以将一个子类数组赋值给一个父类数组变量.但可能 ...

  10. 局部标签(gcc对c的扩展)

    每个语句内嵌表达式都是一个可以声明局部跳转标签的域.一个局部标签只是一个标识符:你可以使用通常的goto语句跳到它--但是只能在它所属的域内这么做.一个局部标签的申明如下:__label__ labe ...