結果

問題 No.120 傾向と対策:門松列(その1)
コンテスト
ユーザー sugim48
提出日時 2015-01-08 23:23:38
言語 C++11(廃止可能性あり)
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 1,162 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,025 ms
コンパイル使用メモリ 119,260 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-05 23:14:26
合計ジャッジ時間 1,834 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	int T; cin >> T;
	while (T--) {
		int N; cin >> N;
		vector<int> L(N);
		for (int i = 0; i < N; i++)
			cin >> L[i];
		sort(L.begin(), L.end());
		vector<int> a(100);
		for (int i = 0; i < N; i++) {
			int j = lower_bound(L.begin(), L.end(), L[i]) - L.begin();
			a[j]++;
		}
		int cnt = 0;
		for (;;) {
			sort(a.begin(), a.end(), greater<int>());
			if (a[0] && a[1] && a[2]) {
				cnt++;
				a[0]--; a[1]--; a[2]--;
			}
			else break;
		}
		cout << cnt << endl;
	}
}
0