結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-18 21:05:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 5,000 ms |
| コード長 | 1,218 bytes |
| コンパイル時間 | 909 ms |
| コンパイル使用メモリ | 99,568 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 03:42:34 |
| 合計ジャッジ時間 | 1,927 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;
int main(void){
int t;
cin >> t;
REP(loop_var, 0, t) {
int n;
cin >> n;
map<int, int> m;
REP(i, 0, n) {
int l;
cin >> l;
if (m.count(l) == 0) {
m[l] = 0;
}
++m[l];
}
vector<int> v;
for (map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {
v.push_back(it->second);
}
int cnt = 0;
while (1) {
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
if (v.size() >= 3 && v[0] >= 1 && v[1] >= 1 && v[2] >= 1) {
v[0]--;
v[1]--;
v[2]--;
cnt++;
continue;
}
break;
}
cout << cnt << endl;
}
}