【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. JavaScript_正则表达式

    [规则]开头结尾    "^The":表示所有以"The"开始的字符串("There","The cat"等):    ...

  2. Kotlin Android Studio 环境搭建

    Kotlin 是一种在 Java 虚拟机上运行的静态类型编程语言,被称之为 Android 世界的Swift,由 JetBrains 设计开发并开源. Kotlin 可以编译成Java字节码,也可以编 ...

  3. jmeter-03 JMeter + Jenkins 集成

    一.准备JMeter 测试计划 mock_api.jmx 接口准备:http://10.1.102.75:8000/mock/api/jmeter 二.jenkins 插件准备  Performanc ...

  4. spoj-ASSIGN-bitDP

    ASSIGN - Assignments #dynamic-programming Problem Your task will be to calculate number of different ...

  5. zoj3656

    题解: 按照位展开,然后一位一位判断 注意判断给出数据是否有问题 代码: #include<cstdio> #include<cmath> #include<algori ...

  6. SpringBoot Mybatis PageHelper插件报错

    SpringBoot2.0.0 MyBatis1.3.2 PageHelper1.1.2插件,但是在启动运行时,抛错:org.springframework.beans.factory.BeanCre ...

  7. LeetCode OJ:LRU Cache(最近使用缓存)

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...

  8. 启动和停止Oracle服务bat脚本

    总所周知,Oracle随开机启动会占很大内存,而你每次想用的时候还得去计算机服务里去找服务.一个一个的启动,比较麻烦. 这里给出两个bat脚本,来直接双击启动和停止Oracle服务[脚本内容来源于网络 ...

  9. mysql function动态执行不同sql语句

    create procedure cps() begin ) default 'user'; set strSql = concat('select * from ',table_user); pre ...

  10. vue.js 源代码学习笔记 ----- 工具方法 env

    /* @flow */ /* globals MutationObserver */ import { noop } from 'shared/util' // can we use __proto_ ...