結果

問題 No.120 傾向と対策:門松列(その1)
コンテスト
ユーザー tottoripaper
提出日時 2015-03-05 00:39:12
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 779 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 303 ms
コンパイル使用メモリ 56,000 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-10 07:40:59
合計ジャッジ時間 703 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <algorithm>

bool used[100];

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

    while(T--){
        int N;
        scanf("%d", &N);

        for(int i=0;i<N;i++){used[i] = false;}
    
        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=0,j=0,k=0;i<N;i++){
            if(used[i]){continue;}
            used[i] = true;
        
            while(j < N && (L[j] <= L[i] || used[j])){j++;}
            if(j == N){break;}
            while(k < N && (L[k] <= L[j] || used[k])){k++;}
            if(k == N){break;}
            
            used[j] = true;
            used[k] = true;
            res++;
        }

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