zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 79 (Rated for Div. 2) A. New Year Garland

    链接:

    https://codeforces.com/contest/1279/problem/A

    题意:

    Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.

    The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them and the store workers will solder a single garland of them. The resulting garland will have all the lamps you provided put in a line. Moreover, no pair of lamps of the same color will be adjacent to each other in this garland!

    For example, if you provide 3 red, 3 green and 3 blue lamps, the resulting garland can look like this: "RGBRBGBGR" ("RGB" being the red, green and blue color, respectively). Note that it's ok to have lamps of the same color on the ends of the garland.

    However, if you provide, say, 1 red, 10 green and 2 blue lamps then the store workers won't be able to build any garland of them. Any garland consisting of these lamps will have at least one pair of lamps of the same color adjacent to each other. Note that the store workers should use all the lamps you provided.

    So Polycarp has bought some sets of lamps and now he wants to know if the store workers can build a garland from each of them.

    思路:

    先把最大的摆出来,然后再相邻的中间插,如果不能全部分割就不行。

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        int t;
        cin >> t;
        while(t--)
        {
            int a[3];
            cin >> a[0] >> a[1] >> a[2];
            sort(a, a+3);
            if (a[2]-1 > a[0]+a[1])
                puts("No");
            else
                puts("Yes");
        }
    
        return 0;
    }
    
  • 相关阅读:
    opencast的docker安装
    编译openwrt_MT7688_hiwooya
    linux中mysql自动同步
    网站服务器迁移
    vtigercrm安装
    ixcache的蜜汁突发故障
    20180628
    pip3 install -r requirements.txt安装超时解决方法
    pytest文档29-allure-pytest
    pytest框架
  • 原文地址:https://www.cnblogs.com/YDDDD/p/12113497.html
Copyright © 2011-2022 走看看