結果

問題 No.1285 ゴミ捨て
ユーザー kya_skikya_ski
提出日時 2020-10-15 19:28:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 71,476 KB
実行使用メモリ 8,196 KB
最終ジャッジ日時 2023-08-19 07:06:48
合計ジャッジ時間 2,358 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 77 ms
7,824 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 30 ms
5,296 KB
testcase_10 AC 65 ms
7,320 KB
testcase_11 AC 58 ms
7,064 KB
testcase_12 AC 40 ms
5,940 KB
testcase_13 AC 40 ms
5,940 KB
testcase_14 AC 70 ms
7,668 KB
testcase_15 AC 47 ms
6,392 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 27 ms
5,104 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 16 ms
4,416 KB
testcase_22 AC 87 ms
8,196 KB
testcase_23 AC 82 ms
8,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>

int main() {
	size_t n;
	std::cin >> n;
	std::set<int> st;
	for (size_t i = 0; i < n; i++) {
		int a;
		std::cin >> a;
		st.insert(a);
	}
	
	int ans = 0;
	while (not st.empty()) {
		int cur = *st.begin();
		st.erase(st.begin());
		ans++;
		
		while (not st.empty()) {
			auto next = st.upper_bound(cur + 1);
			if (next == st.end()) break;
			cur = *next;
			st.erase(next);
		}
	}
	
	std::cout << ans << '\n';
	return 0;
}
0