結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
![]() |
提出日時 | 2017-07-12 00:16:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 2,134 ms |
コンパイル使用メモリ | 180,568 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 15:11:15 |
合計ジャッジ時間 | 2,750 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n,N) for(int i=(n);i<(int) N;i++)#define p(s) cout<<(s)<<endltypedef long long ll;using namespace std;int main(){int T;cin >> T;REP(i,0,T){int N;cin >> N;vector<int> L(N);ll sum = 0;map<int, int> m;REP(i,0,N){cin >> L[i];sum += L[i];m[L[i]]++;}priority_queue<int> pq;for (auto i : m){pq.push(i.second);}int ans = 0;if (m.size() >= 3){while (1){int a = pq.top(); pq.pop();int b = pq.top(); pq.pop();int c = pq.top(); pq.pop();if (c <= 0) break;ans++;pq.push(a - 1);pq.push(b - 1);pq.push(c - 1);}}p(ans);}}