結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
ふーらくたる
|
| 提出日時 | 2016-09-16 12:34:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 5,000 ms |
| コード長 | 1,116 bytes |
| コンパイル時間 | 847 ms |
| コンパイル使用メモリ | 76,804 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 06:29:35 |
| 合計ジャッジ時間 | 1,565 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <iostream>
#include <queue>
#include <vector>
#include <map>
using namespace std;
using Info = pair<int, int>; // (残存数, 竹の長さ)
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
map<int, int> counter;
for (int i = 0; i < n; i++) {
int l;
cin >> l;
counter[l]++;
}
priority_queue<Info> que;
for (auto it = counter.begin(); it != counter.end(); it++) {
Info info = make_pair(it->second, it->first);
que.push(info);
}
int ans = 0;
while (true) {
int num = 0;
vector<Info> temp;
while (!que.empty() && num < 3) {
Info info = que.top(); que.pop();
info.first--;
num++;
if (info.first > 0) temp.push_back(info);
}
for (auto elt : temp) {
que.push(elt);
}
if (num == 3) ans++;
else break;
}
cout << ans << endl;
}
return 0;
}
ふーらくたる