結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー tottoripapertottoripaper
提出日時 2015-03-05 21:16:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 1,050 ms
コンパイル使用メモリ 42,732 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 13:47:00
合計ジャッジ時間 1,150 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <algorithm>

bool used[100];

int main(){
    int T;
    scanf("%d", &T);

    while(T--){
        int N;
        scanf("%d", &N);
        
        int L[100];
        for(int i=0;i<N;i++){
            scanf("%d", L+i);
        }

        std::sort(L, L+N);

        int res = 0;
        for(int i=1;i<=N/3;i++){
            memset(used, 0, sizeof(used));

            bool can = true;
            for(int j=0;j<i;j++){
                int k, l;
                for(k=i;k<N&&(L[k]<=L[j]||used[k]);k++);
                if(k == N){can = false; break;}
                used[k] = true;
                for(l=k+1;l<N&&(L[l]<=L[k]||used[l]);l++);
                if(l == N){can = false; break;}
                used[l] = true;
            }

            if(can){res = i;}
        }

        printf("%d\n", res);
    }
}
0