結果

問題 No.182 新規性の虜
ユーザー kei
提出日時 2016-08-15 23:56:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 593 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 64,320 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 07:33:08
合計ジャッジ時間 2,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int N;
	int ans = 0;
	cin >> N;
	vector<long long> v(N);
	for (int i = 0; i < N;i++) { cin >> v[i]; }
	sort(v.begin(), v.end());
	long long temp = v[0];
	int count = 0;
	if (N == 1) { cout << 1 << endl;return 0; }
	for (int i = 1;i < N;i++) {
		if (temp == v[i]) { count++; continue; }
		else {
			if (count == 0) {
				ans++;
				temp = v[i];
				if (i == N - 1) { ans++; }
			}
			else {
				temp = v[i];
				count = 0;
				if (i == N - 1) { ans++; }
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0