CodeForces 362B Petya and Staircases
题意:一个小男孩要上楼梯,他一次可以走1个台阶或2个台阶或3个台阶,但是有一些台阶是脏的,他不想走在脏台阶上。一共有n个台阶和m个脏台阶,他最开始在第1个台阶上,要走到第n个台阶。问小男孩能不能不踩到脏台阶的前提下走到n个台阶。
思路:对于给定的m个脏序列,先排序后,没有连续的三个数就行。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
const int maxn=1e5+;
const double eps=1e-;
const double pi=acos(-);
#define ll long long
#define clc(a,b) memset(a,b,sizeof(a)) int main()
{
ll n;
int m;
int a[];
scanf("%I64d%d",&n,&m);
clc(a,);
for(int i=; i<=m; i++)
scanf("%d",&a[i]);
sort(a+,a++m);
if(a[]==||a[m]==n)
{
printf("NO\n");
}
else
{
int flag=;
for(int i=; i<=m-; i++)
{
int j=a[i];
if(j+==a[i+]&&j+==a[i+])
{
flag=;
break;
}
}
if(flag)
printf("NO\n");
else
printf("YES\n");
}
return ;
}
CodeForces 362B Petya and Staircases的更多相关文章
- codeforces B. Petya and Staircases 解题报告
题目链接:http://codeforces.com/problemset/problem/362/B 题目意思:给出整数n和m,表示有n级楼梯和m级dirty的楼梯,接下来m个数表示对应是哪一个数字 ...
- CodeForces 362E Petya and Pipes
Petya and Pipes Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- cf B. Petya and Staircases
http://codeforces.com/contest/362/problem/B 先排序,然后判断第一个和最后一个是不是脏的,如果是则输出NO,然后判断其中三个脏的是不是连着的,如果是也输出NO ...
- Codeforces 890C - Petya and Catacombs 模拟
C. Petya and Catacombstime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...
- CodeForces 832B Petya and Exam
B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- codeforces 112B Petya and Square
B. Petya and Square time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 1282C. Petya and Exam (贪心)
链接:https://codeforces.com/contest/1282/problem/C 题意: 有一个人参加考试,考试只有两种题,一种是简单题,每道题耗时固定为a:另一种是困难题,每道题耗 ...
- CodeForces 111B - Petya and Divisors 统计..想法题
找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题.... Program ...
- codeforces 1082G - Petya and Graph 最大权闭合子图 网络流
题意: 让你选一些边,选边的前提是端点都被选了,求所有的边集中,边权和-点权和最大的一个. 题解: 对于每个边建一个点,然后就是裸的最大权闭合子图, 结果比赛的时候我的板子太丑,一直T,(不会当前弧优 ...
随机推荐
- jquery全选,jquery全不选,jquery反选
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- sed线上经典案例之-同时替换多个字符串
回答网友请教的一个问题:配置文件如下:[aaa]cfg1=aaaxxxx=bbbcfg2=ccccfg3=ddd[bbb]cfg1=eeeyyyy=fffcfg2=gggcfg3=hhhcfg4=ii ...
- WebService 学习过程
//------------------------------------------------------------------------------------------ //windo ...
- jdbc 连接Oracle informix Mysql
package com.basicSql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Res ...
- webkit私有css3属性 -webkit-overflow-scrolling:touch;
-webkit-overflow-scrolling:touch;/*允许独立的滚动区域和触摸回弹*/ 这个属性可以提高滚动的平滑度
- poj 1631 Bridging signals (二分||DP||最长递增子序列)
Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9234 Accepted: 5037 ...
- Spring 数据源配置二:多数据源
通过上一节 Spring 数据源配置一: 单一数据源 我们了解单一数据源的配置, 这里我们继续多个数据源的配置 如下(applicationContent.xml 内容) 一: Spring ...
- vs2015 好用插件
备用一下,方便自己查阅 Viasfora 高亮,让自己看代码舒服 ClaudiaIDE 更换编辑器背景 Markdown Mode 编辑Markdown Glyphfriend 图像文字支持 Web ...
- BZOJ 1729: [Usaco2005 dec]Cow Patterns 牛的模式匹配
Description 约翰的N(1≤N≤100000)只奶牛中出现了K(1≤K≤25000)只爱惹麻烦的坏蛋.奶牛们按一定的顺序排队的时候,这些坏蛋总会站在一起.为了找出这些坏蛋,约翰让他的奶牛排好 ...
- Oracle11g密码区分大小写导致database link无法连接
http://f.dataguru.cn/thread-128013-1-1.html Oracle11g的密码默认是区分大小写的,该特性通过初始化参数sec_case_sensitive_logon ...