結果

問題 No.1285 ゴミ捨て
ユーザー bonKotsubonKotsu
提出日時 2020-12-10 13:06:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 172,236 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 00:42:01
合計ジャッジ時間 2,966 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 3 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 9 ms
4,348 KB
testcase_17 AC 9 ms
4,348 KB
testcase_18 AC 9 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 9 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 49 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

int main() {
  int N;
  cin >> N;

  vector<int> a(N);

  rep(i, N) cin >> a[i];

  sort(a.begin(), a.end());

  int ans = 1;
  int begin = 0;
  bool flag = false;
  rep(i, N-1) {
    if (a[i] + 1 >= a[i+1]) {
      if (!flag) {
        flag = true;
        begin = i;
      }

      // 最後の場合の処理
      if (i == N-2) {
        ans = max(ans, i-begin+2);
      }
      continue;
    } else {
      if (!flag) continue;

      ans = max(ans, i-begin);
      flag = false;
    }

  }

  cout << ans << endl;


}
0