結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-08 16:05:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 1,028 bytes |
| コンパイル時間 | 1,932 ms |
| コンパイル使用メモリ | 176,992 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-11-28 15:19:45 |
| 合計ジャッジ時間 | 2,353 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> pi;
int main()
{
int T;
scanf(" %d", &T);
while(T--)
{
int n;
scanf(" %d", &n);
map<int,int> ct;
rep(i,n)
{
int L;
scanf(" %d", &L);
++ct[L];
}
priority_queue<int> que;
for(const auto &x:ct) que.push(x.se);
int ans=0;
while(que.size()>=3)
{
int p[3];
rep(i,3)
{
p[i]=que.top();
que.pop();
}
rep(i,3)
{
--p[i];
if(p[i]>0) que.push(p[i]);
}
++ans;
}
printf("%d\n", ans);
}
return 0;
}