結果
| 問題 | No.120 傾向と対策:門松列(その1) |
| コンテスト | |
| ユーザー |
knewknowl
|
| 提出日時 | 2015-02-10 23:41:52 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 5,000 ms |
| コード長 | 720 bytes |
| 記録 | |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 81,344 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 23:35:24 |
| 合計ジャッジ時間 | 1,096 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
using namespace std;
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
map<int,int> tbl;
scanf("%d",&n);
for(int i=0;i<n;++i){
int l;scanf("%d",&l);
tbl[l]++;
}
priority_queue<int> Q;
for(map<int,int>::iterator it=tbl.begin();it!=tbl.end();++it){
Q.push((*it).second);
}
int ans = 0;
while(true){
if(Q.size()<3) break;
int a = Q.top(); Q.pop();
int b = Q.top(); Q.pop();
int c = Q.top(); Q.pop();
++ans;
if(a>1) Q.push(a-1);
if(b>1) Q.push(b-1);
if(c>1) Q.push(c-1);
}
printf("%d\n",ans);
}
return 0;
}
knewknowl