結果

問題 No.1285 ゴミ捨て
ユーザー hgoto
提出日時 2020-11-15 23:47:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 343 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 77,988 KB
最終ジャッジ日時 2025-01-16 01:04:27
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(begin(a), end(a));
  int ans = n;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] + 1 < a[i + 1]) {
      ans--;
    }
  }
  cout << ans << '\n';
}
0