Codeforces 653A Bear and Three Balls【水题】
题目链接:
http://codeforces.com/problemset/problem/653/A
题意:
给定序列,找是否存在连续的三个数。
分析:
排序~去重~直接判断~~
代码:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 105;
int t[maxn], tt[maxn], vis[1005];
int main (void)
{
int n;cin>>n;
int a = 0;
for(int i = 0; i < n; i++){
cin>>tt[i];
if(vis[tt[i]]) continue;
t[a++] = tt[i];
vis[tt[i]] = 1;
}
sort(t, t + a);
for(int i = 0; i < n - 2; i++){
if(t[i] == t[i + 1] - 1 && t[i + 2] == t[i + 1] + 1){
cout<<"YES"<<endl;
return 0;
}
}
cout<<"NO"<<endl;
return 0;
}
有生之年再一次A没做出来。比赛的时候就是打死也没想到去重这回事,如果做出来了,肯定不至于掉这么多分。。。。真是无语。。。
总结:多试试几组数,不能方!
Codeforces 653A Bear and Three Balls【水题】的更多相关文章
- codeforces 653A A. Bear and Three Balls(水题)
题目链接: A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) A. Bear and Three Balls 水题
A. Bear and Three Balls 题目连接: http://www.codeforces.com/contest/653/problem/A Description Limak is a ...
- codeforces 653A Bear and Three Balls
A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Beta Round #37 A. Towers 水题
A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...
- codeforces 677A A. Vanya and Fence(水题)
题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- 【codeforces】Bear and Three Balls(排序,去重)
Bear and Three Balls Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I6 ...
随机推荐
- HDU 5414 CRB and String (字符串,模拟)
题意:给两个字符串s和t,如果能插入一些字符使得s=t,则输出yes,否则输出no.插入规则:在s中选定一个字符c,可以在其后面插入一个字符k,只要k!=c即可. 思路:特殊的情况就是s和t的最长相同 ...
- Tomcat和搜索引擎网络爬虫的攻防
不知道广大程序员朋友们注意到一个现象么?使用百度是无法搜索到淘宝网的网页.为什么会造成这种现象?这就要从网络爬虫说起了. 咱们程序员假如自己搭设个人网站,在上面分享少量自己的技术文章,面临的一个重要问 ...
- linux centos 中目录结构的含义
文件夹的含义 文件夹路径 含义 / 所有内容的开始 /root 系统管理员目录 /bin 缺省的liunx工具,就是存储命令的目录 环境变量等等 /etc 系统的配置 配置文件的存 ...
- gitlab利用ssh方式拉取代码
问题1: Bad owner or permissions on .ssh/config的解决 当为本机配一个固定用户名远程登录某主机时,配置了一个config文件,但是在执行ssh免密码登录时报如下 ...
- this.$emit('on-select-change' emit里面不能写大写字母
this.$emit('on-select-change' emit里面不能写大写字母 刚试了下 也能写大写 但是 两边就都写一样就完了,就都写成带-的就完了
- 最短路 || UOJ 19 寻找道路
UOJ j19 寻找道路 在有向图G中,每条边的长度均为 1,现给定起点和终点,请你在图中找一条从起点到终点的最短路径,该路径满足以下条件: 路径上的所有点的出边所指向的点都直接或间接与终点连通. * ...
- MySQL-01 MySQL数据库安装指南
学习要点 MySQL数据库的安装和设置 下载mysql mysql官网:https://www.mysql.com/downloads/ 主要版本: Oracle MySQL Cloud Servic ...
- es6(三set和map数据结构)
es6中提供了一个新的数据结构Set,他有点类似数组,但和数组不同的是,在里面你如果写入重复的值的话,他不会显示重复值. const s =new Set(); [2,3,4,5,6,6,6,7,8, ...
- luogu 1608 路径统计--最短路计数
https://www.luogu.org/problemnew/show/P1608 题意https://www.cnblogs.com/rmy020718/p/9440588.html相似,建议还 ...
- g++使用总结
学习C和C++的同学应该都知道,gcc是一款跨平台的C/C++编译器,可以在Linux/Windows平台下使用,具有十分强大的功能,结构也十分灵活,并且可以通过不同的前端模块来支持各种语言,如Jav ...