結果
| 問題 | No.120 傾向と対策:門松列(その1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-22 15:31:56 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 723 bytes |
| 記録 | |
| コンパイル時間 | 1,177 ms |
| コンパイル使用メモリ | 225,596 KB |
| 実行使用メモリ | 16,512 KB |
| 最終ジャッジ日時 | 2026-07-05 18:33:46 |
| 合計ジャッジ時間 | 2,696 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll T;
cin>>T;
while(T--){
ll N;
cin>>N;
map<ll,ll> L;
for(int i=0;i<N;i++){
ll a;
cin>>a;
L[a]++;
}
priority_queue<ll> Q;
for(auto p:L)Q.push(p.second);
ll an=0;
while(Q.size()>2){
vector<ll> V;
for(int i=0;i<3;i++){
V.push_back(Q.top());
Q.pop();
}
an++;
for(int i=0;i<3;i++){
if(V[i]>1)Q.push(V[i]-1);
}
}
cout<<an<<endl;
}
}