結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
maine_honzuki
|
| 提出日時 | 2020-05-17 14:39:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 5,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 1,776 ms |
| コンパイル使用メモリ | 177,528 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 06:51:09 |
| 合計ジャッジ時間 | 2,741 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
map<int, int> cnt;
cin >> N;
while (N--) {
int L;
cin >> L;
cnt[L]++;
}
priority_queue<int> que;
for (auto& p : cnt)
que.push(p.second);
int ans = 0;
while (que.size() >= 3) {
int a[3] = {};
for (int i = 0; i < 3; i++) {
a[i] = que.top();
que.pop();
}
for (int i = 0; i < 3; i++) {
if (a[i] > 1)
que.push(a[i] - 1);
}
ans++;
}
cout << ans << endl;
}
}
maine_honzuki