結果
問題 | No.1285 ゴミ捨て |
ユーザー |
|
提出日時 | 2024-03-23 19:03:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 4,028 ms |
コンパイル使用メモリ | 253,444 KB |
最終ジャッジ日時 | 2025-02-20 13:27:50 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll = long long;using ld = long double;int N, cnt = 1, same = 0;ll A[101010];int main() {cin >> N;for (int i = 0; i < N; i++) cin >> A[i];sort(A, A + N);bool flag = false;for (int i = 0; i < N - 1; i++) {if (!flag && A[i] + 1 == A[i + 1]) {flag = true;cnt++;}if (A[i] == A[i + 1]) {same++;if (same > cnt) cnt++;} else same = 0;}cout << cnt << endl;return 0;}