Codeforces 362B. Petya and Staircases
来源:互联网 发布:兰芝淘宝旗舰店 编辑:程序博客网 时间:2024/04/26 15:13
B. Petya and Staircases
思路:一打眼看有DP的思想,dp是模拟了这个过程,来看最后是否到达。如果我们可以准确地找出来到达的条件是什么,直接判断则更为简单,此题就是。不能有连续的三个数字出现
#include <iostream>#include <cstdio>#include<algorithm>using namespace std;int main(){ int m,n; int num[4000]; bool flag = true; cin>>n>>m; for ( int i=0; i<m; i++ ) { scanf("%d",&num[i]); if ( num[i]==1 || num[i]==n ) flag = false; } if ( flag ) { sort( num,num+m); for ( int i=2; i<m; i++ ) if ( num[i]==num[i-1]+1 && num[i]==num[i-2]+2 ) { flag = false; break; } } if ( flag ) cout<<"YES"<<endl; else cout<<"NO"<<endl;}
0 0
- Codeforces 362B Petya and Staircases
- CodeForces 362B Petya and Staircases
- CodeForces 362B Petya and Staircases
- Codeforces 362B. Petya and Staircases
- Petya and Staircases CodeForces
- B. Petya and Staircases
- Codeforces Round #212 (Div. 2) B. Petya and Staircases
- Codeforces Round #212 (Div. 2) B. Petya and Staircases
- B. Petya and Staircases----思维题
- Codeforces Round #212 (Div. 2) A. Two Semiknights Meet /B. Petya and Staircases
- CodeForces 111B - Petya and Divisors
- CodeForces 111B Petya and Divisors
- 【CodeForces】[66B]Petya and Countryside
- CodeForces 66B - Petya and Countryside(水题)
- CodeForces 832B Petya and Exam
- codeforces B. Petya and Exam (模拟)
- codeforces 832B (Petya and Exam)
- CodeForces 832 B. Petya and Exam
- 四边形不等式优化
- class属性中间存在空格,到底是什么意思呢?!
- centos64 上安装mysql
- js常见兼容性问题举例包含完整代码
- OpenJudge1.4编程基础之逻辑表达式与条件分支之 03:奇偶数判断
- Codeforces 362B. Petya and Staircases
- jdk1.8中的filter应用
- ubuntu 14.04 LTS软件中心闪退
- Java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader 解决方案
- 相机标定遇到无法打开源文件“cvut.h”解决之道
- android:getSystemService详解
- js数组的常用方法
- Leetcode #167 Two Sum II
- extjs 6.2 熟悉开发环境 hello world