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;
    }
    
  • 相关阅读:
    HDU 4389 X mod f(x)
    SRM 400(1-250pt, 1-500pt)
    FZU 2113 Jason的特殊爱好
    POJ 3208 Apocalypse Someday
    HDU 4734 F(x)
    HDU 3555 Bomb
    HDU 2089 不要62
    poj2488(A Knight's Journey)
    poj3267(The Cow Lexicon)
    poj2513(Colored Sticks)
  • 原文地址:https://www.cnblogs.com/YDDDD/p/12113497.html
Copyright © 2011-2022 走看看