結果

問題 No.1285 ゴミ捨て
ユーザー bonKotsubonKotsu
提出日時 2020-12-10 13:07:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 667 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 169,812 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 07:27:50
合計ジャッジ時間 2,756 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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+1);
      flag = false;
    }

  }

  cout << ans << endl;


}
0