結果
問題 | No.1285 ゴミ捨て |
ユーザー |
![]() |
提出日時 | 2020-11-14 15:29:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 694 bytes |
コンパイル時間 | 1,948 ms |
コンパイル使用メモリ | 175,176 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-11-28 21:51:41 |
合計ジャッジ時間 | 3,748 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int N; cin >> N; int A[N]; map<int, int> m; int max_v = 0; for (int i = 0; i < N; i++) { cin >> A[i]; m[A[i]]++; chmax(max_v, m[A[i]]); } sort(A, A + N); bool flag = false; for (int i = 1; i < N; i++) { if (A[i - 1] + 1 == A[i]) { flag = true; break; } } if (flag) { cout << max(max_v, 2) << "\n"; } else { cout << max_v << "\n"; } return 0; }