結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-06-26 15:11:03 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 719 bytes | 
| コンパイル時間 | 2,440 ms | 
| コンパイル使用メモリ | 202,740 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-06-26 15:11:07 | 
| 合計ジャッジ時間 | 4,075 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | RE * 4 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll,ll>;
#define FOR(i, n) for (ll i = 0; (i) < (ll)(n); ++(i))
#define FOR3(i, m, n) for (ll i = (m); (i) < (ll)(n); ++(i))
#define fi first
void solve(){
	int N; cin>>N;
    int cnt[101]{};
    int x;
    FOR(i,N) cin>>x,++cnt[x];
    set<pi> st;
    FOR3(i,1,101)if(cnt[i]) st.emplace(cnt[i],i);
    int ans=0;
    while(st.size()>2){
        ++ans;
        pi p[3];
        FOR(i,3){
            p[i]=st.extract(*st.rbegin()).value();
        }
        FOR(i,3) if(--p[i].fi>0) st.emplace(p[i]); 
    }
    cout<<ans<<'\n';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1; cin>>t;
    for(;t--;) solve();
}
            
            
            
        