結果

問題 No.182 新規性の虜
ユーザー Kura
提出日時 2019-02-22 22:06:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 64,832 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 08:34:52
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int k = 0;
	sort(a.begin(), a.end());
	if (n>2) {
		for (int i = 1; i < n - 1; i++) {
			if (a[i - 1] != a[i] && a[i] != a[i + 1]) {
				k++;
			}
		}
		if (a[0] != a[1])k++;
		if (a[n - 2] != a[n - 1])k++;
	}
	else if (n == 2) {
		if (a[0] != a[1])k+=2;
	}
	else {
		k++;
	}
	cout << k << endl;
}
0