博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AtCoder Beginner Contest 072
阅读量:7294 次
发布时间:2019-06-30

本文共 1750 字,大约阅读时间需要 5 分钟。

这应该是我第二次打AtCoder, 题目其实并不难,就是自己经验不足想复杂了,再加上自己很笨,愣是做了97分钟才全做出来(最后三分钟,有点小激动。。),看着前面大牛半个小时都搞完了,真心膜拜一下,代码其实没什么可看的,题目也没什么可说的,就是为了贴出来总结经验,下次再战!

链接:http://abc072.contest.atcoder.jp/

A:直接做就可以了

#include
using namespace std;const int INF = (1 << 30);const int N = 100000 + 5;const double eps = 1e-8;const int M = 100 + 5;const int MOD = 1e9;char str[N];int main(){ int x, t; scanf("%d %d", &x, &t); printf("%d\n", max(x - t, 0));}

 

B:也是直接做就可以了

#include
using namespace std;const int INF = (1 << 30);const int N = 100000 + 5;const double eps = 1e-8;const int M = 100 + 5;const int MOD = 1e9;char str[N];int main(){ scanf("%s", str); int len = strlen(str); for(int i = 0; i < len; i += 2) putchar(str[i]); puts("");}

 

C:只要考虑a[i+1] + a[i] + a[i+2]就可以了

#include
using namespace std;const int INF = (1 << 30);const int N = 100000 + 5;const double eps = 1e-8;const int M = 100 + 5;const int MOD = 1e9;int a[N];int main(){ int n, ans = 0, x, maxn = 0; scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%d", &x); ++ a[x]; if(x > maxn) maxn = x; } for(int i = 0; i <= maxn; i++) ans = max(ans, a[i] + a[i + 1] + a[i + 2]); printf("%d\n", ans);}

 

D:没想到这么直接,直接swap就行了,我以为有什么套路结果卡着半天,最后还剩3分钟的时候直接交上去竟然AC了。。。神奇。。。

#include
using namespace std;const int INF = (1 << 30);const int N = 100000 + 5;const double eps = 1e-8;const int M = 100 + 5;const int MOD = 1e9;int a[N];int main(){ int n, ans = 0; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]); for(int i = 1; i < n; i++) if(a[i] == i) swap(a[i], a[i + 1]), ans++; if(a[n] == n) ans++; printf("%d\n", ans);}

 

转载于:https://www.cnblogs.com/Pretty9/p/7468182.html

你可能感兴趣的文章
基于QT Plugin框架结构
查看>>
Windows Server 2008 R2 如何启用WINS服务
查看>>
一天一种设计模式之五-----代理模式
查看>>
抽象类和模板模式
查看>>
《ASP.NET MVC企业实战》(二) MVC开发前奏
查看>>
32.C#--方法中使用out参数做登录判断
查看>>
error
查看>>
quartz+spring框架动态调整频率实践
查看>>
两款高性能并行计算引擎Storm和Spark比较
查看>>
The application could not be verified
查看>>
HaProxy介绍,安装及配置
查看>>
mysql基本操作命令
查看>>
易优cms问一下大家 二级目录 真的完全不能装吗
查看>>
GSLX680触摸屏驱动移植
查看>>
group_concat
查看>>
django创建一个管理员用户
查看>>
批量修改nginx配置文件
查看>>
一文读懂 JAVA 异常处理
查看>>
Linux快速入门打开你的学习之道
查看>>
怎么给工作中重要的pdf文件加密
查看>>