mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Upload via code
This commit is contained in:
40
FZOI/grouping.cpp
Normal file
40
FZOI/grouping.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define int long long
|
||||
#define endl "\n"
|
||||
#define IMX LONG_LONG_MAX
|
||||
#define IMN LONG_LONG_MIN
|
||||
using namespace std;
|
||||
|
||||
/* toothless. #17 */
|
||||
|
||||
const int N = 1e7 + 10;
|
||||
const int M = 2e3 + 5;
|
||||
|
||||
int n, mn = IMX;
|
||||
int a[N];
|
||||
|
||||
signed main()
|
||||
{
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i ++ )
|
||||
{
|
||||
cin >> a[i];
|
||||
}
|
||||
sort(a, a + n);
|
||||
int cnt = 1;
|
||||
for (int i = 1; i < n; i ++ )
|
||||
{
|
||||
if (a[i] == a[i - 1] + 1)
|
||||
{
|
||||
cnt ++ ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mn = min(mn, cnt);
|
||||
cnt = 1;
|
||||
}
|
||||
}
|
||||
mn = min(mn, cnt);
|
||||
cout << mn << endl;
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user