-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCF_AutoMaticDoor.cpp
More file actions
executable file
·86 lines (69 loc) · 1.06 KB
/
CF_AutoMaticDoor.cpp
File metadata and controls
executable file
·86 lines (69 loc) · 1.06 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
using namespace std;
inline unsigned long long mn(unsigned long long a,unsigned long long b){
return a<b?a:b;
}
int main() {
int n,m,k,a,j;
unsigned long long d,nts,prev,c,et,mnv;
cin >>n>>m >>a >> d;
unsigned long long clnts[m];
nts=1;
k=1;
j=0;
for(int i=0;i<m;i++){
scanf("%llu",&clnts[i]);
//cin >> clnts[i];
//cout << clnts[i] <<" " ;
}
et=k*a;
mnv=mn(et,clnts[j]);
if(mnv==et)
k++;
else
j++;
prev=mnv;
for(;j<m&&k<=n;)
{
et=k*a;
mnv=mn(et,clnts[j]);
if(mnv-prev>d){
prev=mnv;
nts++;
}
if(mnv==et)
k++;
else
j++;
}
if(j<m){
for(int i=j;i<m;i++){
if(clnts[i]-prev>d){
nts++;
prev=clnts[i];
}
//cout << ar[ii]<<" ";
}
}
else if(k<=n){
if(k<=n){
if((d-prev)<(k*a)){
nts+=n-k;
}
else{
int tmp=d/a;
nts+=n-tmp;
}
}
// for(int i=k;i<=n;i++){
// et=i*a;
// if(et-prev>d){
//
// nts++;
// prev=et;
// }
// }
}
cout << nts;
return 0;
}