結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-04 20:30:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 759 bytes |
| コンパイル時間 | 2,277 ms |
| コンパイル使用メモリ | 204,240 KB |
| 最終ジャッジ日時 | 2025-02-07 21:24:13 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int T; cin >> T;
rep(_,T) {
int N; cin >> N;
map<int,int> mp;
rep(i,N) {
int L; cin >> L;
mp[L]++;
}
priority_queue<int> pq;
for(auto [_, c] : mp) pq.push(c);
int ans = 0;
while(int(pq.size()) >= 3) {
int a = pq.top(); pq.pop();
int b = pq.top(); pq.pop();
int c = pq.top(); pq.pop();
a -= c; b -= c;
ans += c;
if(a > 0) pq.push(a);
if(b > 0) pq.push(b);
}
cout << ans << "\n";
}
}