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 ...
随机推荐
- IF-MIB::ifTable = No Such Object available on this agent at this OID
在server端口执行如下命令 [root@localhost ~]# snmpwalk -v2c -c public 客户端ip ifIF-MIB::ifTable = No Such Object ...
- RHEL5.8上SAMBA源码修改打包安装流程
之前一直使用系统自带的SAMBA,近期需要对SAMBA代码做一些修改,然后还是打算用RPM包的方式来安装部署. 这个流程本身不复杂,在这里记录下来,免得在另外写说明文档. 关键词:RHEL5.8, s ...
- 8.2.6 PEB —— PEB结构值不正确的问题
书中作者使用 dt _PEB xxxxxx 命令来查看当前进程的PEB结构. 实际操作后PEB结构显示的成员值: 作为进程链表的LDR结构居然没有值,这显然是不正常的,地址也没有输错,问题到底出在哪里 ...
- 汇编3栈帧,参数传递,串操作,混合汇编,x64,asm文件
基础知识2 选择结构 通过判断 + 条件跳转指令来实现 循环结构 通过判断 + 条件跳转指令来实现(会有一个向上跳转的语句) 函数调用约定 C调用约定: 由外部平衡栈 标准调用约定 : 由函数内部平衡 ...
- python django项目断点调试
- No-9.函数基础
函数基础 目标 函数的快速体验 函数的基本使用 函数的参数 函数的返回值 函数的嵌套调用 在模块中定义函数 01. 函数的快速体验 1.1 快速体验 所谓函数,就是把 具有独立功能的代码块 组织为一个 ...
- C语言程序返回值为int的时候,不同值代表不同的意义
这个是我自己给自己的代码定的标准,方便自己阅读与编码.他人代码情况不可套用 1 执行成功 0 出现错误,不影响程序执行 -1 执行失败 -2 程序内部致命错误,退出程序
- spring-mvc jackson配置json为空不输出
使用的spring-mvc版本是4.1.6,jackson版本是2.1.4 在spring-mvc配置文件中添加以下代码就行 <mvc:annotation-driven> <mvc ...
- Django关于SQL注意事项
执行原生SQL: from django.db import connection, connections cursor = connection.cursor() cursor.execute( ...
- 转载 vue的基础使用
转载https://www.cnblogs.com/majj/p/9957597.html#top vue的介绍 前端框架和库的区别 nodejs的简单使用 vue的起步 指令系统 组件的使用 过滤器 ...