結果

問題 No.1285 ゴミ捨て
ユーザー kya_skikya_ski
提出日時 2020-10-15 19:28:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-05-06 14:20:05
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 67 ms
7,936 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 28 ms
5,376 KB
testcase_10 AC 58 ms
7,424 KB
testcase_11 AC 55 ms
7,168 KB
testcase_12 AC 39 ms
6,272 KB
testcase_13 AC 40 ms
6,144 KB
testcase_14 AC 66 ms
7,552 KB
testcase_15 AC 45 ms
6,528 KB
testcase_16 AC 12 ms
5,376 KB
testcase_17 AC 13 ms
5,376 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 26 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 16 ms
5,376 KB
testcase_22 AC 71 ms
8,192 KB
testcase_23 AC 70 ms
8,192 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