【Codeforces】Round #491 (Div. 2) 总结
【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) 总结的更多相关文章
- Codeforces Round #491 (Div. 2)
Codeforces Round #491 (Div. 2) https://codeforces.com/contest/991 A #include<bits/stdc++.h> us ...
- 【Codeforces】Codeforces Round #491 (Div. 2) (Contest 991)
题目 传送门:QWQ A:A - If at first you don't succeed... 分析: 按照题意模拟 代码: #include <bits/stdc++.h> usin ...
- Codeforces Round #491 (Div. 2) E - Bus Number + 反思
E - Bus Number 最近感觉打CF各种车祸.....感觉要反思一下, 上次读错题,这次想当然地以为18!肯定暴了longlong 而没有去实践, 这个题我看到就感觉是枚举每个数字的个数,但是 ...
- Codeforces Round #491 (Div. 2)部分题解
这场比赛好鬼畜啊,,A题写崩了wa了4遍,心态直接爆炸,本来想弃疗了,结果发现BCD都是傻逼题.. A. If at first you don't succeed...(容斥原理) 题目大意: 有$ ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
随机推荐
- C#之多线程
多线程在C#中使用得非常频繁,线程之间的充分利用显得尤为重要,一般的写法都是得不到充分利用资源,本人针对多线程写了一种方法,可以充分利用资源,保证每次同时启动10条线程,现在执行完马上再启动一条,总之 ...
- php入门(三)
PHP 面向对象: 在php5中 var就是public的别名. 变量 $this 代表自身的对象. PHP_EOL;为换行符 构造函数+析构函数 <?php class Site { /* 成 ...
- python学习笔记(字典乱码)
博主总结下 python中字典中包含中文时,使用过程中出现乱码 json.dumps(params, encoding="UTF-8", ensure_ascii=False) p ...
- 高性能Go并发
1.管道chan吞吐极限10,000,000,单次Put,Get耗时大约100ns/op,无论是采用单Go程,还是多Go程并发(并发数:100, 10000, 100000),耗时均没有变化,Go内核 ...
- 如何高效的使用 Git
-- 代码昨天还是运行好好的今天就不行了. 代码被删了. 突然出现了一个奇怪的 bug,但是没人知道怎么回事. 如果你出现过上面的任何一种情况,那本篇文章就是为你准备的. 除了知道 git add, ...
- StringUtils.isNumeric()的特殊点
String str = "-1"; StringUtils.isNumeric(str) 返回的是false StringUtils.isNumeric()方法在判断字符串是否是 ...
- Java SHA256/Base64转.NET(C#)实现---(华为云云市场.NET版本加密方式)
前言: 工作需要,对接华为云应用市场的 API 接口,由于维护团队都是 .NET 所以用 .NET 来开发. 简单了解一下 SHA256 加密算法,本质就是一个 Hash,与 MD5 相比就是计算量大 ...
- grub2 windows版安装
一.BIOS方式,grub2安装 查看磁盘情况 E:\grub-2.02-for-windows>wmic diskdrive list brief Caption DeviceID Model ...
- IOS-APP主流UI框架结构
一.简单示例 说明:使用APP主流UI框架结构完成简单的界面搭建 搭建页面效果: 二.搭建过程和注意点 1.新建一个项目,把原有的控制器删 ...
- Linux用root强制踢掉已登录用户;用fail2ban阻止ssh暴力破解root密码
Linux用root强制踢掉已登录用户 首先使用w命令查看所有在线用户: [root@VM_152_184_centos /]# w 20:50:14 up 9 days, 5:58, 3 use ...