题目链接:

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【水题】的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  5. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  6. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  7. Codeforces Beta Round #37 A. Towers 水题

    A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...

  8. codeforces 677A A. Vanya and Fence(水题)

    题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. 【codeforces】Bear and Three Balls(排序,去重)

    Bear and Three Balls Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I6 ...

随机推荐

  1. 安装nginx的一些注意事项

    1.如何彻底屏蔽掉Nginx的banner 为了安全或者某些个人的原因,如果要屏蔽掉nginx的banner,要修改以下几个位置: src/http/ngx_http_header_filter_mo ...

  2. Android内存泄露(全自动篇)

    写了可执行文件启动器Launcher.jar及一些批处理,通过它们就可以自动的以一定的时间间隔提取Hprof和进程的内存信息: 一.需要的库 可执行文件启动器:lib\Launcher.jar 注:关 ...

  3. 遍历NSView下的子视图方法

    如何遍历NSView下的子视图呢 for (NSView *aview in [SuperV subviews]) { if([aview isMemberOfClass:[NSButton clas ...

  4. Web开发者不容错过的10个HTML5工具

    HTML5已经成为当今世界的一个必然组成部分.由于World Wide Web万维网是使用超文本标记语言来架构和呈现的,于是HTML5成为了最流行的编程语言之一.随着网络的不断扩张,Web开发人员非常 ...

  5. (转)Spring+JDBC组合开发

    http://blog.csdn.net/yerenyuan_pku/article/details/52882435 搭建和配置Spring与JDBC整合的环境 使用Spring+JDBC集成步骤如 ...

  6. Android(java)学习笔记164:开发一个多界面的应用程序之不同界面间互相传递数据(短信助手案例)

    1.首先我们看看下面这个需求: 这里我们在A界面上,点击这个按钮"选择要发送的短信",开启B界面上获取网络上各种短信祝福语,然后B界面会把这些网络祝福语短信发送给A界面到" ...

  7. MySQL数据表查询操作

    准语法结构:编写DQL时一定要严格按照此语法的顺序来实现!/* SELECT [ALL | DISTINCT] ALL表示查询出所有的内容 DISTINCT 去重 {* | 表名.* | 表名.字段名 ...

  8. how to get many stars on Github?

    some key points: 1: make a beautiful README file2: use some GIF (google some tools to convert videos ...

  9. uva1439 Exclusive Access 2

    感觉这道题读题有点难..似乎和现实联系的比较密切1.每个process的两个资源可以顺序反一下2.p->q,q->s不可以同时进行 p->q,p->s可以 输出最长等待链输出每 ...

  10. 对faster rcnn代码讲解的很好的一个

    http://www.cnblogs.com/houkai/p/6824455.html http://blog.csdn.net/u014696921/article/details/6032142 ...