結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
![]() |
提出日時 | 2015-08-02 02:43:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 498 bytes |
コンパイル時間 | 730 ms |
コンパイル使用メモリ | 76,688 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 00:45:20 |
合計ジャッジ時間 | 1,355 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
#include<iostream> #include<map> #include<queue> #define REP(i,n) for(int i=0;i<n;++i) using namespace std; int main(){ int t; cin >> t; while (t--){ map<int, int> mp; int n; cin >> n; REP(i,n){ int l; cin >> l; mp[l]++; } priority_queue<int> pq; for (auto it : mp) pq.push(it.second); int ans = 0; while (pq.size() >= 3){ ans++; int x[3]; REP(i, 3) x[i] = pq.top(), pq.pop(); REP(i, 3) if (x[i] > 1) pq.push(x[i] - 1); } cout << ans << endl; } return 0; }