結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-04-23 18:02:56 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 32 ms / 5,000 ms | 
| コード長 | 1,088 bytes | 
| コンパイル時間 | 778 ms | 
| コンパイル使用メモリ | 88,452 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-04 15:20:54 | 
| 合計ジャッジ時間 | 1,539 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 4 | 
ソースコード
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int t;
    std::cin >> t;
    for(int i=0; i<t; ++i){
        int n;
        std::cin >> n;
        std::map<int, int> lNumMap;
        for(int j=0; j<n; ++j){
            int input;
            std::cin >> input;
            ++lNumMap[input];
        }
        std::vector<std::pair<int, int>> lNumPair(2, std::make_pair(0, 0));
        for(auto it=lNumMap.begin(); it!=lNumMap.end(); ++it){
            lNumPair.push_back(std::make_pair(it->first, it->second));
        }
        int ans = 0;
        while(true){
            std::sort(lNumPair.begin(), lNumPair.end(), [](const std::pair<int, int>& l, std::pair<int, int>& r){
                return l.second>r.second;
            });
            if(lNumPair[2].second==0) break;
            for(int j=0; j<3; ++j){
                --lNumPair[j].second;
            }
            ++ans;
        }
        std::cout << ans << "\n";
    }
        
    return 0;
}
            
            
            
        