题目链接:

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. MY $MYVIMRC

    set nocompatiblesource $VIMRUNTIME/vimrc_example.vim"source $VIMRUNTIME/mswin.vim"behave m ...

  2. gulp自动化构建工具使用

    gulpfile.js: var gulp = require("gulp"); var imagemin = require("gulp-imagemin") ...

  3. Spotlight安装

    刚才技术群的一个朋友在安装Spotligh出现了一些问题,所以本人临时写个简单的教程 1.下载安装包(安装包地址:https://pan.baidu.com/s/1c2tmqyc),解压,然后傻瓜式安 ...

  4. linux centos 中目录结构的含义

    文件夹的含义  文件夹路径 含义  / 所有内容的开始   /root 系统管理员目录  /bin 缺省的liunx工具,就是存储命令的目录   环境变量等等 /etc 系统的配置    配置文件的存 ...

  5. how to make a function from using global var to not using it

    let say, we want to find the bottom left node in a tree.one way to do it is using global vars: /** * ...

  6. CAD交互绘制带周长面积的矩形框(网页版)

    主要用到函数说明: _DMxDrawX::DrawLine 绘制一个直线.详细说明如下: 参数 说明 DOUBLE dX1 直线的开始点x坐标 DOUBLE dY1 直线的开始点y坐标 DOUBLE ...

  7. Android开发中JavaBean类和序列化知识的理解

    原创文章,转载请注明出处:http://www.cnblogs.com/baipengzhan/p/6296121.html Android开发中,我们经常用到JavaBean类以及序列化的知识,但经 ...

  8. NFS和DHCP服务

    1. NFS NFS,Network File System的简写,即网络文件系统.网络文件系统是FreeBSD支持的文件系统中的一种,也被称为NFS: NFS允许一个系统在网络上与他人共享目录和文件 ...

  9. 使用scrapy爬取suning

    # -*- coding: utf-8 -*- import scrapy from copy import deepcopy class SuSpider(scrapy.Spider): name ...

  10. 剑指Offer(书):从尾到头打印链表

    题目:输入一个链表,按链表值从尾到头的顺序返回一个ArrayList. 分析:若不允许修改原链表的值,则可以使用栈来实现,也可以使用另外一个ArrayList做中转的数据. public ArrayL ...