結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー pekempey
提出日時 2016-12-22 21:12:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 171,996 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 14:53:48
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int T;
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}
		sort(a.begin(), a.end());
		int ans = 0;
		while (true) {
			int j = -1;
			for (int i = 1; i < (int)a.size() - 1; i++) {
				if (a.front() != a[i] && a[i] != a.back()) {
					j = i;
					break;
				}
			}
			if (j == -1) {
				break;
			}
			ans++;
			a.pop_back();
			a.erase(a.begin() + j);
			a.erase(a.begin());
		}
		cout << ans << endl;
	}
}
0