【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. mvn deploy返回400错误的几种可能

    user credentials are wrong url to server is wrong user does not have access to the deployment reposi ...

  2. python中装饰器的执行细节

    本文代码借用 廖雪峰的python教程(官网:http://www.liaoxuefeng.com/) 不了解装饰器的可以先看教程 直接上带参数装饰器的代码 def log(text): def de ...

  3. 英语每日阅读---8、VOA慢速英语(翻译+字幕+讲解):脸肓症患者记不住别人的脸

    英语每日阅读---8.VOA慢速英语(翻译+字幕+讲解):脸肓症患者记不住别人的脸 一.总结 一句话总结: a.neural abnormalities are more widespread:Duc ...

  4. unity3D用什么语言开发好?

    unity3D用什么语言开发好? 一.总结 一句话总结:选c# 同时U3D团队也会把支持的重心转移到C#,也就是说文档和示例以及社区支持的重心都在C#,C#的文档会是最完善的,C#的代码实例会是最详细 ...

  5. HIVE学习(待更新)

    1 安装hive 下载 http://mirrors.shu.edu.cn/apache/hive/hive-1.2.2/,红框中的不需要编译. 由于hive是默认将元数据保存在本地内嵌的 Derby ...

  6. ana3+opencv+TensorFlow+NVIDIAGPU 安装

    http://blog.csdn.net/qq_30611601/article/details/79067982 这个博客写的挺完整的 当你发现你的anna下载的贼鸡儿的慢,你就需要使用清华的镜像网 ...

  7. SQL 添加字段

    制定添加在那个字段后面 ALTER TABLE `szq`.`org_sales_daily` ADD COLUMN `trade_id_onl_count` int(11) NOT NULL DEF ...

  8. css3之calc()

    初识calc() 在使用calc()之前,我也只是听说有这么一个东西,但在用过之后我才发现这个功能其实很实用. calc()其实就是英文calculate(计算)的缩写,它看起来像个函数吧? 其实不是 ...

  9. commons-fileupload实现上传进度条的显示

    本文将使用   apache fileupload   ,spring MVC   jquery 实现一个带进度条的多文件上传, 由于fileupload 的局限,暂不能实现每个上传文件都显示进度条, ...

  10. VS2015常用快捷键总结(转)

    生成解决方案 F6,生成项目Shift+F6 调试执行F5,终止调试执行Shift+F5 执行调试Ctrl+F5 查找下一个F3,查找上一个Shift+F3 附加到进程Ctrl+Alt+P,逐过程F1 ...