結果

問題 No.1823 Tricolor Dango
ユーザー mannshi222jp
提出日時 2022-01-28 22:43:08
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 3,409 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 29,056 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 09:11:25
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 4 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int compare_int(const void *a, const void *b);

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main()
{
        int T, N;
        int A[2*100000];

        bool flg, dng;

        scanf( "%d\n", &T );

        for( int t; t < T; t++ ) {
                scanf( "%d\n", &N );
                for( int a = 0; a < N -1; a++ ) {
                        scanf( "%d ", A+a );
                }
                scanf( "%d\n", A+N-1 );

                qsort( A, N, sizeof(int), compare_int );

                flg = false;
                               while( 1 ) {
                        int f, s, t;

                        flg = true;
                        dng = false;
                        f = 0;
                        s = 0;
                        t = 0;
                        while( 1 ) {
                                dng = false;
                                if( f >= N ) {
                                        flg = false ;
                                        break;
                                }
                                if( A[f] == 0 ) {
                                        f++;
                                        continue;
                                }
                                A[f]--;
                                s = f+1;
                                while( 1 ) {
                                        if( s >= N ) {
                                                flg = false;
                                                break;
                                        }
                                        if( A[s] == 0 ) {
                                                s++;
                                                continue;
                                        }
                                        A[s]--;
                                        break;
                                }
                                if( flg == false ) {
                                        break;
                                }

                                t = s+1;
                                                               while( 1 ) {
                                        if( t >= N ) {
                                                flg = false;
                                                break;
                                        }
                                        if( A[t] == 0 ) {
                                                t++;
                                                continue;
                                        }

                                        A[t]--;
                                        flg = true;
                                        dng = true;
                                        break;;
                                }
                                if( dng == true ) {
                                        break;
                                }
                        }


                        if( flg == true ) {
                                printf("Yes\n");
                                break;
                        }
                        else {
                                printf("No\n");
                                break;
                        }
                }
        }

        return 0;
}
0