CF883A.Automatic Door

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is an automatic door at the entrance of a factory. The door works in the following way:

  • when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside,
  • when one or several people come to the door and it is open, all people immediately come inside,
  • opened door immediately closes in dd seconds after its opening,
  • if the door is closing and one or several people are coming to the door at the same moment, then all of them will have enough time to enter and only after that the door will close.

For example, if d=3d=3 and four people are coming at four different moments of time t1=4t_{1}=4 , t2=7t_{2}=7 , t3=9t_{3}=9 and t4=13t_{4}=13 then the door will open three times: at moments 44 , 99 and 1313 . It will close at moments 77 and 1212 .

It is known that nn employees will enter at moments a,2a,3a,...,naa,2·a,3·a,...,n·a (the value aa is positive integer). Also mm clients will enter at moments t1,t2,...,tmt_{1},t_{2},...,t_{m} .

Write program to find the number of times the automatic door will open. Assume that the door is initially closed.

输入格式

The first line contains four integers nn , mm , aa and dd ( 1<=n,a<=1091<=n,a<=10^{9} , 1<=m<=1051<=m<=10^{5} , 1<=d<=10181<=d<=10^{18} ) — the number of the employees, the number of the clients, the moment of time when the first employee will come and the period of time in which the door closes.

The second line contains integer sequence t1,t2,...,tmt_{1},t_{2},...,t_{m} ( 1<=ti<=10181<=t_{i}<=10^{18} ) — moments of time when clients will come. The values tit_{i} are given in non-decreasing order.

输出格式

Print the number of times the door will open.

输入输出样例

  • 输入#1

    1 1 3 4
    7
    

    输出#1

    1
    
  • 输入#2

    4 3 4 2
    7 9 11
    

    输出#2

    4
    

说明/提示

In the first example the only employee will come at moment 33 . At this moment the door will open and will stay open until the moment 77 . At the same moment of time the client will come, so at first he will enter and only after it the door will close. Thus the door will open one time.

首页