結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-20 22:35:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 5,000 ms |
| コード長 | 903 bytes |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 104,672 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-22 23:06:06 |
| 合計ジャッジ時間 | 1,653 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
int main()
{
int t;
cin >> t;
while(--t >= 0){
int n;
cin >> n;
map<int, int> cnt;
for(int i=0; i<n; ++i){
int len;
cin >> len;
++ cnt[len];
}
vector<int> v;
for(auto p : cnt)
v.push_back(p.second);
sort(v.rbegin(), v.rend());
int ret = 0;
if(v.size() >= 3)
ret = min({n / 3, (n - v[0]) / 2, n - v[0] - v[1]});
cout << ret << endl;
}
return 0;
}