zoukankan      html  css  js  c++  java
  • cf B. Petya and Staircases

    http://codeforces.com/contest/362/problem/B

    先排序,然后判断第一个和最后一个是不是脏的,如果是则输出NO,然后判断其中三个脏的是不是连着的,如果是也输出NO,否则输出YES

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <algorithm>
     4 #define LL __int64
     5 #define maxn 100010
     6 using namespace std;
     7 
     8 LL a[maxn];
     9 LL n,m;
    10 
    11 int main()
    12 {
    13     while(scanf("%I64d%I64d",&n,&m)!=EOF)
    14     {
    15         for(int i=0; i<m; i++)
    16         {
    17             scanf("%I64d",&a[i]);
    18         }
    19         sort(a,a+m);
    20         bool flag=true;
    21         for(int i=0; i<m; i++)
    22         {
    23             if(a[i+1]-a[i]==1&&a[i+2]-a[i+1]==1&&i+2<m)
    24             {
    25                 flag=false;
    26                 printf("NO
    ");
    27                 break;
    28             }
    29             else if(i==m-1||i==0)
    30             {
    31                 if(a[i]==n||a[i]==1)
    32                 {
    33                     printf("NO
    ");
    34                     flag=false;
    35                     break;
    36                 }
    37             }
    38         }
    39         if(flag) printf("YES
    ");
    40     }
    41     return 0;
    42 }
    View Code
  • 相关阅读:
    学习进度笔记01
    进度报表十一
    进度报表十
    进度日报九
    进度日报八
    进度日报七
    第七周总结
    进度报表六
    第一阶段冲刺6
    第一阶段冲刺5
  • 原文地址:https://www.cnblogs.com/fanminghui/p/3949926.html
Copyright © 2011-2022 走看看