結果

問題 No.1823 Tricolor Dango
ユーザー mannshi222jpmannshi222jp
提出日時 2022-01-28 22:43:08
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 3,409 bytes
コンパイル時間 1,408 ms
コンパイル使用メモリ 28,620 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-28 21:11:33
合計ジャッジ時間 3,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 23 ms
4,384 KB
testcase_19 AC 55 ms
4,380 KB
testcase_20 AC 23 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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