-
Notifications
You must be signed in to change notification settings - Fork 0
/
D.cpp
64 lines (63 loc) · 1.16 KB
/
D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
fastio;
long long n,m,i,mn,count=0,sum=0;
static long long ara[200005],c[200005];
mn=INT_MAX;
cin>>n>>m;
for(i=0;i<m;i++)
{
cin>>ara[i];
}
if(m==n)
{
cout<<0;
return 0;
}
else if(m==0)
{
cout<<1;
return 0;
}
sort(ara,ara+m);
for(i=0;i<m;i++)
{
if(i==0)
{
if(ara[i]!=1)
{
c[count]=ara[i]-1;
mn=ara[i]-1;
count++;
}
continue;
}
if(ara[i]-ara[i-1]>1)
{
c[count]=ara[i]-ara[i-1]-1;
mn=min(mn,ara[i]-ara[i-1]-1);
count++;
}
if(i==m-1)
{
if(ara[i]!=n)
{
c[count]=n-ara[i];
mn=min(mn,n-ara[i]);
count++;
}
}
}
for(i=0;i<count;i++)
{
if(c[i]%mn==0)
sum+=(c[i]/mn);
else
sum+=1+(c[i]/mn);
}
cout<<sum;
return 0;
}