zoukankan      html  css  js  c++  java
  • 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没做出来。比赛的时候就是打死也没想到去重这回事,如果做出来了,肯定不至于掉这么多分。。。。真是无语。。。
    总结:多试试几组数,不能方!

  • 相关阅读:
    vue $emit的使用
    flask config 环境变量配置
    get请求
    下载及安装
    测试用例写作
    系统测试
    测试方法
    软件质量
    测试基础
    子网掩码
  • 原文地址:https://www.cnblogs.com/Tuesdayzz/p/5758721.html
Copyright © 2011-2022 走看看