結果
| 問題 | No.120 傾向と対策:門松列(その1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-16 15:57:38 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 5,000 ms |
| コード長 | 593 bytes |
| 記録 | |
| コンパイル時間 | 801 ms |
| コンパイル使用メモリ | 105,336 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 14:19:26 |
| 合計ジャッジ時間 | 1,752 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
void solve(){
int n;cin>>n;
map<int,int> A;
for(int i = 0; n > i; i++){
int x;cin>>x;
A[x]++;
}
priority_queue<int> B;
for(auto x: A){
B.push(x.second);
}
int ans = 0;
while(B.size() >= 3){
auto a1 = B.top();B.pop();
auto a2 = B.top();B.pop();
auto a3 = B.top();B.pop();
if(--a1)B.push(a1);
if(--a2)B.push(a2);
if(--a3)B.push(a3);
ans++;
}
cout << ans << endl;
}
int main(){
int t;cin>>t;
for(int i = 0; t > i; i++){
solve();
}
}