-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10061.cpp
57 lines (55 loc) · 1.33 KB
/
10061.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
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
/* ÎâÉñÃÀÈç» O(¡É_¡É)O~ */
int q[200055];
int main()
{
int T;
scanf("%d",&T);
int t=T;
while (T--){
int n,m,l;
scanf("%d%d%d",&n,&m,&l);
// s.clear();
for (int j=1;j<=n;j++){
int g;
scanf("%d",&g);
q[j]=g;
}
q[n+1]=m;q[0]=0;
sort(q,q+n+2);
int now=0;
int pos=0,last=0,key=0;
int ans=0;
while (now<m){
while (pos<=n+1 && q[pos]-now<=l) pos++;
pos--;
if (q[pos]!=now){
key=l-(q[pos]-now);
now=q[pos];
ans++;
}else{
int len=q[pos+1]-now-(l+1);
ans+=len/(l+1)*2;
now=now+len/(l+1)*(l+1);
len+=l+1;
now+=key+1;
ans++;
key=(l-(key+1));
if (q[pos+1]-now<=l) continue;
now+=key+1;
ans++;
key=(l-key-1);
if (q[pos+1]-now<=l) continue;
now+=key+1;
ans++;
key=(l-key-1);
if (q[pos+1]-now<=l) continue;
}
}
printf("Case #%d: %d\n",t-T,ans);
}
return 0;
}