Educational Codeforces Round 79 A. New Year Garland

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

Thinking: we may assume R> = G> = B, because the largest number of R, it is bounded by R, may only be a G or a B or G between adjacent two of R a and B

           According to the following strategy configuration, first put all of the R, then R between adjacent two discharge because a B R R + 1 have voids, they must be able to complete all of the B discharge, there may be two adjacent between the first front or R R or R is empty after the last

                                     Next G first position to fill up empty between two adjacent R, obviously if it can not fill up the empty position between two adjacent R, you can not construct a sequence consistent with the meaning of the questions

                                     If there are remaining G, the first on the front of the first and after the last R R, G and then put in a left or right side of each B (B actually put on both sides of each one G, is also consistent with the meaning of problems when, however the general hypothesis R> = G> = B, considered separately G (B), two adjacent R

                                     Placed between a G (B), must be able to G (B) is done)

In summary, as long as the G + B> = R-1 can When G + B = R-1, R, R + 1, placed before the first or after the last one R or R between adjacent two of R G or B to a

        When G + B> R + 1, B is bled remaining R + 1-B can put a single position G, so G left G- (R + 1-B) = G + BR-1> 0 a, which together with B, and B has a position B, B- (G + BR-1) = R + 1-G> = 1, it is possible to complete the rest of the G discharge, i.e. each only one B-B between the left or right after a release G, there are two adjacent R

official:

 

 

#
 #include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--){
        int m1=0,m2=0,m3=0,a,b,c;
        cin>>a>>b>>c;
        ll sum=a+b+c;
        if(a>b){
            if(a>c){m1=a;if(b>c)m2=b,m3=c;else m2=c,m3=b;
            }
            else{m1=c;if(b>a)m2=b,m3=a;else m2=a,m3=b;
            }
        }
        else{
            if(b>c){m1=b;if(a>c)m2=a,m3=c;else m2=c,m3=a;
            }
            else{m1=c;if(b>a)m2=b,m3=a;else m2=a,m3=b;
            }
        }
        if(m2+m3>=m1-1)
        cout<<"Yes"<<endl;//if(sum-m1>=m1-1&&m2-m1<m3)
        else cout<<"No"<<endl;
    }
    
    
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/wyh447154317/p/12165901.html