結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー hogeover30hogeover30
提出日時 2015-01-29 17:46:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 67,184 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 07:38:13
合計ジャッジ時間 1,276 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <map>
using namespace std;
int main()
{
    int T; cin>>T;
    while (T--) {
        int n; cin>>n;
        map<int, int> a;
        while (n--) {
            int l; cin>>l; a[l]++;
        }
        int res=0;
        while (a.size()>2) {
            map<int,int>::iterator i=a.begin();
            decltype(i) j=i; ++j;
            decltype(i) k=j; ++k;
            i->second--; if (i->second==0) a.erase(i);
            j->second--; if (j->second==0) a.erase(j);
            k->second--; if (k->second==0) a.erase(k);
            ++res;
        }
        cout<<res<<endl;
    }
}
0