結果

問題 No.1285 ゴミ捨て
ユーザー startcpp
提出日時 2020-11-13 22:25:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 70,192 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-22 21:18:11
合計ジャッジ時間 1,770 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

//大きい容器から見ていくと、重ねられるときは重ねるべきで、このときのまとまりの個数は
//sort(a)しておいて、a[i] + 1 >= a[i + 1]になっているiの個数 + 1で求まる。
#include <iostream>
#include <algorithm>
using namespace std;

int n;
int a[100000];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	
	int ans = 1;
	for (i = 0; i + 1 < n; i++) if (a[i] + 1 >= a[i + 1]) ans++;
	cout << ans << endl;
	
	return 0;
}
0