結果
| 問題 | 
                            No.1285 ゴミ捨て
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kya_ski
                         | 
                    
| 提出日時 | 2020-10-15 19:32:13 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 83 ms / 2,000 ms | 
| コード長 | 536 bytes | 
| コンパイル時間 | 588 ms | 
| コンパイル使用メモリ | 72,292 KB | 
| 実行使用メモリ | 8,064 KB | 
| 最終ジャッジ日時 | 2024-11-28 21:32:20 | 
| 合計ジャッジ時間 | 2,292 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 22 | 
ソースコード
#include <iostream>
#include <set>
#include <cassert>
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;
	assert(st.size() == n);
	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);
		}
	}
	
	assert(ans == 1 or ans == 2);
	
	std::cout << ans << '\n';
	return 0;
}
            
            
            
        
            
kya_ski