結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー pekempeypekempey
提出日時 2016-12-22 21:12:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 169,864 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 05:43:55
合計ジャッジ時間 2,660 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

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