Problem:


Score : 300 points

Problem Statement

In a public bath, there is a shower which emits water for T seconds when the switch is pushed.

If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.
Note that it does not mean that the shower emits water for T additional seconds.

N people will push the switch while passing by the shower.
The i-th person will push the switch t_i seconds after the first person pushes it.

How long will the shower emit water in total?

Constraints

1 ≤ N ≤ 200,000

1 ≤ T ≤ 10^9

0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9

T and each t_i are integers.

Input

Input is given from Standard Input in the following format:

N T
t_1 t_2 ... t_N

Output

Assume that the shower will emit water for a total of X seconds. Print X.

Sample Input 1

2 4
0 3

Sample Output 1

7

Three seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.

Sample Input 2

2 4
0 5

Sample Output 2

8

One second after the shower stops emission of water triggered by the first person, the switch is pushed again.

Sample Input 3

4 1000000000
0 1000 1000000 1000000000

Sample Output 3

2000000000

Sample Input 4

1 1
0

Sample Output 4

1

Sample Input 5

9 10
0 3 5 7 100 110 200 300 311

Sample Output 5

67



Sample input:
2 4
0 3


Sample output:
7

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

X = 0
Time = 0

for i in range(N):

    if Time <= t[i]:
        X += T
        Time = t[i] + T

print(X)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())        #　N人、　一回のシャワーの時間:T秒
t = list(map(int, input().split()))     # n人目がおす時間のタイミング

X = 0
Time = 0    #全体の時間

for i in range(N):

    if Time < t[i]:
        X += T
        Time = t[i] + T

print(X)

Submission status: Wrong Answer

Solution code:
# ABC060C - Sentou (ARC073C)
n, t = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
ans, cur = 0, lst[0]
for i in lst[1:]:
    ans += min(t, i - cur)
ans += t
print(ans)

Submission status: Wrong Answer

Solution code:
n, time = map(int, input().split())
 
arr = list(map(int, input().split())) + [float("inf")]
 
left, temp, sum_time = 0, 0, 0
 
for t in arr[1:]:
  if t <= left + time:
    temp = t
  else:
    sum_time += (temp + time - left)
    left, temp = t, t
 
print(sum_time)

Submission status: Wrong Answer

Solution code:
n,t=map(int,input().split())
arr=list(map(int,input().split()))
s=arr[0]
ans=0
tmp=0
for i in range(1,n):
  if arr[i]-s<=t:
    tmp=arr[i]-s
  else:
    ans+=tmp+t
    tmp=0
ans+=tmp+t
print(ans)

Submission status: Wrong Answer

Solution code:
N,T=map(int,input().split())
T_S=list(map(int,input().split()))
ans=0
for i in range(N):
    if i==0:
        ans+=T
    else:
        if ans>T_S[i]:
            tmp=abs(ans-T_S[i])
            ans-=tmp
            ans+=T
        else:
            ans+=abs(ans-T_S[i])
            ans+=T
print(ans)

Submission status: Wrong Answer

Solution code:
N,T=map(int,input().split())
T_S=list(map(int,input().split()))
ans=0
for i in range(N):
    if i==0:
        ans+=T
    else:
        if ans>T_S[i]:
            tmp=abs(ans-T_S[i])
            ans-=tmp
            ans+=T
        else:
            ans+=T
print(ans)

Submission status: Wrong Answer

Solution code:
n,t=map(int,input().split())
T=list(map(int,input().split()))
ans=t
end=t
for i in range(1,n):
  ans+=t-max(0,end-T[i])
  end=max(end,T[i])+t
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n,t=map(int,input().split())
T=list(map(int,input().split()))
endtime=0
for i in T:
  if endtime<i+t:
    endtime=endtime-(endtime-i)+t
print(endtime)

Submission status: Wrong Answer

Solution code:
import sys
n,t=map(int,input().split())
T=list(map(int,input().split()))
endtime=0
for i in T:
  if endtime>i+t:
    endtime=endtime-(endtime-i)+t
print(endtime)

Submission status: Wrong Answer

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = 0
for i in range(0,num):
	if int(t[i])<time:
		ans += int(t[i])
	else:
		ans += time
ans += time
print ans

Submission status: Wrong Answer

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = 0
for i in range(0,num-1):
	if int(t[i])<time:
		ans += int(t[i])
	else:
		ans += time
ans += time
print ans

Submission status: Wrong Answer

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = 0
for i in range(0,num-2):
	if int(t[i])<time:
		ans += int(t[i])
	else:
		ans += time
ans += time
print ans

Submission status: Wrong Answer

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = 0
for i in range(num-1):
	if int(t[i])<time:
		ans += int(t[i])
	else:
		ans += time
ans += time
print ans

Submission status: Wrong Answer

Solution code:
num,time = map(int,raw_input().split())
t = raw_input().split()
ans = 0
for i in range(len(t)-1):
	if int(t[i])<time:
		ans += int(t[i])
	else:
		ans += time
ans += time
print ans

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())

a = list(map(int,input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])
su = 0
for i in range(n-1):
    if b[i] >= k:
        su += k
    else:
        su += b[i]
print(su)

Submission status: Wrong Answer

Solution code:
n,t=map(int,input().split())
l=list(map(int,input().split()))
time=t
i=1
if len(l)==1:
    print(t)
else:
    while True:
        if l[i]-time<0:
            time=l[i]+t
        else:
            time+=t
        if i==n-1:
            break
        i+=1
    print(time)

Submission status: Wrong Answer

Solution code:
n,t = map(int,input().split())
y = list(map(int,input().split()))
res = 0
s = 0
for i in range(n):
    x = y[i]-res 
    if x>0:
        s += x
        res += t
    else:
        res = y[i]+t-s
print(res)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
start = 0
for i in range(N):
    if t[i] > T:
        ans += t[i - 1] + T - start
        start = t[i]
    if i == N - 1:
        ans += t[i] + T - start

print(ans)

Submission status: Wrong Answer

Solution code:
N,T = map(int,input().split())
t = list(map(int,input().split()))

X = 0
for i in range(1,N):
    if i == N - 1:
        X += T
    if t[i] - t[i-1] >= T:
        X += T
    else:
        X += t[i] - t[i-1]

print(X)

Submission status: Wrong Answer

Solution code:
n,t = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
count = 0
time = 0
for i in range(n-1):
    if i != n - 1:
        time += ar[i+1] - ar[i]
        count += t
    if time < count:
        count -= count - time
count += t
print(count)

Submission status: Wrong Answer

Solution code:
N, T = map( int, input().split())
S = list( map( int, input().split()))
S.append(10**10)
ans = 0
now = 0
for i in range(1,N+1):
    ans += min( S[i] - now, T)
    # if T[i] - now >= T:
    #     ans += T
    # else:
    #     ans += T[i] - now
print(ans)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=0
for i in c:
    if i<=b:
        d=i+b
    else:
        d=d+b
print(d)

Submission status: Wrong Answer

Solution code:
N, T =map(int,input().split())
t=list(map(int,input().split()))
ans=0
for i in range (N):
    ans=min(ans+T,t[i]+T)
print (ans)

Submission status: Wrong Answer

Solution code:
N,T = map(int,input().split())
a = list(map(int,input().split()))

sum =0
for i in range(N-1):
    if a[i+1]>T:
        sum+=T
    else:
        sum+=a[i+1]-a[i]
print(sum+T)

Submission status: Wrong Answer

Solution code:
N,T=(int(i) for i in input().split())
t = [int(i) for i in input().split()]
a=0
for b in range(N-1):
    if (t[b+1] - t[b]) < T:
        a = a + t[b+1] - t[b]
    else:
        a = a + T
a=a+4
print(a)

Submission status: Wrong Answer

Solution code:
n,t = map(int,input().split())
tp = list(map(int,input().split()))
ret = 0
m = 0
for i in tp:
  h = t if m < i else i + t - m
  m += h
  ret += h
print(ret)

Submission status: Wrong Answer

Solution code:
n,t = input().split()
N = int(n)
T = int(t)
t_list = []

t = list(input().split())
t_list = list(map(int,t))

sum_time = 0

for j in range(len(t_list)):
	if(t_list[j]-sum_time <= T):
		sum_time = t_list[j]
	elif(t_list[j]-sum_time > T):
		sum_time += T
sum_time += T
print(sum_time)

Submission status: Wrong Answer

Solution code:
n,t = input().split()
N = int(n)
T = int(t)
t_list = []

t = list(input().split())
t_list = list(map(int,t))

sum_time = 0

for j in range(len(t_list)):
	if(t_list[j]-sum_time <= 0):
		sum_time = t_list[j]+T
	elif(t_list[j]-sum_time > 0):
		sum_time += T

print(sum_time)

Submission status: Wrong Answer

Solution code:
n,t = input().split()
N = int(n)
T = int(t)
t_list = []

t = list(input().split())
t_list = list(map(int,t))

sum_time = 0

for j in range(len(t_list)):
	if(t_list[j] <= T*j):
		sum_time = t_list[j]+T
	elif(t_list[j] > T*j):
		sum_time += T

print(sum_time)

Submission status: Wrong Answer

Solution code:
# input
N, T = map(int, input().split())
T_lst = list(map(int, input().split()))

ans = 0

for i in range(N):
    if T_lst[i] <= T_lst[i - 1] + T:
        ans += T_lst[i] - T_lst[i - 1]
    else:
        ans += T

ans += T
print(ans)

Submission status: Wrong Answer

Solution code:
n, t = map(int, input().split())
times = list(map(int, input().split()))
total = 0
for i in range(1, n):
  if times[i] - times[i-1] >= t:
    total += t
  else:
    total = times[i] - times[i-1]

print(total + t)

Submission status: Wrong Answer

Solution code:
n, t = map(int, input().split())
times = list(map(int, input().split()))
total = 0
for i in range(1, n):
  if times[i] - times[i-1] >= t:
    total += t
  else:
    total = times[i]

print(total + t)

Submission status: Wrong Answer

Solution code:
n, t = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
for i in range(len(l)):
  if l[i] < ans:
    ans = l[i]+t
  else:
    ans += t
print(ans)

Submission status: Wrong Answer

Solution code:
tmp = list(map(int,input().split()))
n,t = tmp[0],tmp[1]
ts = list(map(int,input().split()))
ans = t
for i in ts[1:]:
  if i < t:
    ans += (t-i)
  else:
    ans += t
print(ans)

Submission status: Wrong Answer

Solution code:
n,t = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
answer,start = 0,0
for i in range(1,n):
	if a[i] > a[i-1]+t:
		end = a[i-1]+t
		answer += end-start
		start = a[i]
	if i == n-1:
		end = a[i]+t
		answer += end-start
print(answer)

Submission status: Wrong Answer

Solution code:
n,T=map(int,input().split())
t=list(map(int,input().split()))
ts=[]
tf=[]
ts.append(t[0])
tb=t[0]
for i in t:
  if(i>ts[-1]+T):
    tf.append(tb+T)
    ts.append(i)
  tb=i
tf.append(t[-1]+T)
time=0
#print(ts)
#print(tf)
for i in range(len(ts)):
  time+=tf[i]-ts[i]
print(time)

Submission status: Wrong Answer

Solution code:
n,t=map(int,input().split())

Submission status: Wrong Answer

Solution code:
def c_Sentou(N, T, t):
    ans = 0
    for time in t:
        if ans > time:
            ans = time
        ans += T
    return ans

N,T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
print(c_Sentou(N, T, t))

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split(" "))
t = list(map(int, input().split(" ")))

shower = 0

for i in range(1, N):
    if t[i] >= T:
        shower += T
    else:
        shower += t[i]

shower += T
print(shower)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split(" "))
t = list(map(int, input().split(" ")))

shower = 0

for i in range(1, N):
    if t[i] >= T:
        shower += T
    else:
        shower += t[i]

print(shower)

Submission status: Wrong Answer

Solution code:
n,t = map(int,input().split())
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])
if len(a) > 1:
    if t > a[1]:
        x = a[1]
    else:
        x = t
else:
    x = t
for i in range(1,len(a)):
    if i == n-1:
        x += t
    elif t <= a[i]:
        x += t
    else:
        x += a[i]
print(x)

Submission status: Wrong Answer

Solution code:
num,time = map(int, input().split())
times = [int(n) for n in input().split()]
stop = time
total = 0
for i in range(1,num):
    if times[i]<=stop:
        total += times[i]-times[i-1]
    else:
        total += stop-times[i-1]
    stop = times[i]+time
total += times[-1]+time
print(total)

Submission status: Wrong Answer

Solution code:
num,time = map(int, input().split())
times = [int(n) for n in input().split()]
start = 0
stop = time
total = 0
for i in range(1,num):
    if times[i]<stop:
        total += times[i]-times[i-1]
    else:
        total += stop-times[i-1]
    stop = times[i]+time
total += times[-1]+time
print(total)

Submission status: Wrong Answer

Solution code:
N,T=map(int,input().split())
tm=list(map(int,input().split()))


t_sum=0
t_point=0

for i in tm:
    if i >= t_point:
        t_sum += T
        t_point += T
    else:
        t_sum += i+T-t_point
        t_point = i+T

print(t_sum)

Submission status: Wrong Answer

Solution code:
#N,Tの取得
l = list(map(int, input().split()))
N = l[0]
T = l[1]

#秒のリストを取得
tl = list(map(int, input().split()))

bt = 0 #直前のスイッチを押した時間
gt = 0 #秒数総和
for i, t in enumerate(tl):
    if t - bt > T:
        gt += T #スイッチオフの時はT秒追加
    else:
        gt += t - bt #スイッチがオンのとき、前回からの経過時間を加算
    bt = t
        

print(str(gt))

Submission status: Wrong Answer

Solution code:
n, t = (int(i) for i in input().split())
b = [int(i) for i in input().split()]
x = 0
for i in range(n):
    if b[i] < t:
        x += b[i]
    else:
        x += t
print(x+t)

Submission status: Wrong Answer

Solution code:
n, t = (int(i) for i in input().split())
b = [int(i) for i in input().split()]
x = 0
print(sum(b)+t)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
k=list(map(int,input().split()))

time=0
for i in range(a-1):
    tc=k[i+1]-k[i]
    if tc<b:
        time = time+tc
    else:
        time=time+b
print(time)

Submission status: Wrong Answer

Solution code:
n, T = map(int, input().split())
t = list(map(int, input().split()))
total = T
for i in t:
    if T < i:
        total += T
    else:
        total += i
    
print(total)

Submission status: Wrong Answer

Solution code:
n, T = map(int, input().split())
t = list(map(int, input().split()))
total = 0
for i in t:
    total += T - i
print(total)

Submission status: Wrong Answer

Solution code:
n, T = map(int, input().split())
t = list(map(int, input().split()))
total = T
for i in t:
    total += T - i
print(total)

Submission status: Wrong Answer

Solution code:
n, t = map(int, input().split())
t_l = [int(i) for i in input().split()]

cost = t

for i in range(n - 1):
    cost += min(t, t_l[i] - t_l[i - 1])
print(cost)

Submission status: Wrong Answer

Solution code:
n, t = map(int, input().split())
t_l = [int(i) for i in input().split()]

cost = t

for i in range(n - 1):
    t += min(t, t_l[i] - t_l[i - 1])
print(cost)

Submission status: Wrong Answer

Solution code:
n, T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]

print(n, T, t)

sum = 0

for i in range(1,n):
    interval = t[i] - t[i-1]
    if interval < T:
        sum += interval
    else:
        sum += T

sum += T

print(sum)

Submission status: Wrong Answer

Solution code:
N,T = map(int,input().split())
t=list(map(int,input().split()))

def count_time(N,T,t):
    cnt = T
    for i in range(N-1):
        tt =t[i+1]-t[i]        
        if tt <=T:
            cnt += tt
        else:
            cnt += T
    return cnt

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = t
for i in range(N-1):
	if(next < n[i+1]):
		total += t
		next = n[i+1]
	else:
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = t
for i in range(N-1):
	if(next < n[i+1]):
		print("true")
		total += t
		next = n[i+1]
	else:
		print("false")
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = 0
for i in range(N-1):
	if(next+t <= n[i+1]):
		print("true")
		total += t
		next = n[i+1]
	else:
		print("false")
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
ts = list(map(int, input().split()))
s = 0;
for i in range(N - 1):
    s += min(ts[i + 1], T)
print(s)

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = 0
for i in range(N-1):
	if(next+t <= n[i+1]):
		total += t
		next = n[i+1]
	else:
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Submission status: Wrong Answer

Solution code:
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []
zo  = [0, T]
leng = T
"""
d = set()
for i in range(N):
    d = d | set(range(a[i], a[i] + T))
"""
for i in range(N):
    if  a[i] + T <= zo[1]:
        pass
    elif a[i] <= zo[1] and zo[1] <= a[i] + T:
        leng += a[i] + T - zo[1]
        zo[1] = a[i] + T
    elif zo[1] <= a[i]:
        zo[0] = a[i]
        zo[1] = a[i] + T
        leng += T
    
print(leng)




print(leng)

Submission status: Wrong Answer

Solution code:
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []
zo  = [0, T]
leng = T
"""
d = set()
for i in range(N):
    d = d | set(range(a[i], a[i] + T))
"""
for i in range(N):
    if  a[i] + T <= zo[1]:
        pass
    elif a[i] <= zo[1] and zo[1] <= a[i] + T:
        leng += a[i] + T - zo[1]
        zo[1] = a[i] + T
    elif zo[1] <= a[i]:
        zo[0] = a[i]
        zo[1] = a[i] + T
        leng += T
    print(leng)




print(leng)

Submission status: Wrong Answer

Solution code:
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []
zo  = [0, T]
leng = T
"""
d = set()
for i in range(N):
    d = d | set(range(a[i], a[i] + T))
"""
for i in range(N):
    if  a[i] + T <= zo[1]:
        pass
    elif a[i] <= zo[1] and zo[1] <= a[i] + T:
        leng += a[i] + T - zo[1]
        zo[1] = a[i] + T
    elif zo[1] <= a[i]:
        zo[0] = a[i]
        zo[1] = a[i] + T
        leng += T
    print(zo, leng)

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = t
for i in range(N-1):
	if(next <= n[i+1]):
		total += t
		next = n[i+1]
	else:
		total += n[i+1]-n[i]
		next = n[i+1] +t

if(next <= n[N-1]):
	total += t
else:
	total += t
print(total)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
ts = list(map(int, input().split()))
for i in range(len(ts)):
    if ts[i] > T:
        ts[i] = T
print(sum(ts) + T)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

_all = N * T
sabun = 0

for i in range(1, N):
    if T < t[i]:
        sabun += 0
    else:
        sabun += T - t[i]


print(_all - sabun)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

_all = N * T
sabun = 0

for i in range(1, N):
    print(i)
    if T < t[i]:
        sabun += 0
    else:
        sabun += T - t[i]
        print(sabun)


print(_all - sabun)

Submission status: Wrong Answer

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

_all = N * T
sabun = 0

for i in range(0, N):
    if T < t[i]:
        sabun += 0
    else:
        sabun += T - t[i]

print(_all - sabun)

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = t
for i in range(N-1):
	if(next+t <= n[i+1]):
		total += t
		next = n[i+1]
	else:
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Submission status: Wrong Answer

Solution code:
N, Y = map(int, input().split())
t = list(int (i) for i in input().split())
w=0
for i in range(len(t)-1):
    if t[i+1]-t[i]<=Y:
        w+=t[i+1]-t[i]
    else:
        w+=Y
print(w)

Submission status: Wrong Answer

Solution code:
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = t
for i in range(N-1):
	if(next <= n[i+1]):
		total += t
		next = n[i+1]
	else:
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Submission status: Wrong Answer

Solution code:
def sentou(NT, ts):
    N, T = map(int, NT.split())
    before_oshitano = None
    total_s = 0
    for t in map(int, ts.split()):
        if before_oshitano is None:
            before_oshitano = t
            continue
        elif T > (t - before_oshitano):
            total_s += t
        else:
            total_s += T
    total_s += T

    print(total_s)


sentou(input(), input())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


N,T = map(int,raw_input().split(" "))
t = map(int,raw_input().split(" "))
X = 0
sum = 0

if(N == 1):
	print T
else:
	for n in range(N-1):
		if(t[n+1]<=T):
			X = t[n+1] + X - t[n]
		else:
			X = X + T

	X = X + T

	print X

Submission status: Wrong Answer

Solution code:
N, T = list(map(int, input().split()))
t =  list(map(int, input().split()))
ans = N*T
t.pop(0)   # startが0なの忘れてた
for i in t:
    if i < T:
        ans -= T - i
print(ans)

Submission status: Wrong Answer

Solution code:
N, T = list(map(int, input().split()))
t =  list(map(int, input().split()))
ans = N*T
for i in t:
    if i < T:
        ans -= T - i
print(ans)

Submission status: Wrong Answer

Solution code:
f=map(int, raw_input().split())
s=map(int, raw_input().split())

total=0

for i in range(f[0]):
    total+=min(f[1], s[i]-total)

total+=f[1]

print total

Submission status: Wrong Answer

Solution code:
N, T = map(int, raw_input().split())
t = map(int, raw_input().split())

X = T

for i in range(0, N):
    if t[i] > T:
        X += T
    else:
        X += t[i]

print(X)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    s = set()
    for x in t:
        s |= set(range(x, x+T))
    print(len(s))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, t = map(int, input().split())
T = list(map(int, input().split()))

counter = 0
timer = 0
T_position = 0
for i in range(T[-1] + t):
#  print(counter, timer, T_position)
  if T[T_position] == i:
    timer = t
    if T_position != len(T) - 1:
      T_position += 1
  if timer > 0:
    counter += 1
  timer -= 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
N, T = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

def main():
    ans = 0
    a = A
    while a:
        curr = a.pop(0)
        next = a[0] if a else float('inf')
        ans += min(T, next - curr)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N, T = [int(s) for s in input().split()]
PS = [int(s) for s in input().split()]

def main():
    t = T
    ps = PS
    ans = 0
    while ps:
        p = ps.pop(0)
        ans += min(ps[0] - p, t) if ps else t
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, t = LI()
    T = LI()
    sentou = [0 for _ in range(T[-1] + t + 1)]

    i = 0
    while i < len(T):
        sentou[T[i]] += 1
        sentou[T[i] + t] -= 1
        i += 1

    j = 1
    while j < len(sentou):
        sentou[j] += sentou[j - 1]
        j += 1

    print(n * t - (sum(sentou) - (sentou.count(1) + len(sentou) - sentou.count(1) - sentou.count(0))))

solve()

Submission status: Time Limit Exceeded

Solution code:
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, t = LI()
    T = LI()
    sentou = [0 for _ in range(T[-1] + t + 1)]

    for ele_T in T:
        sentou[ele_T] += 1
        sentou[ele_T + t] -= 1

    for i in range(1, len(sentou)):
        sentou[i] += sentou[i - 1]

    print(n * t - (sum(sentou) - (sentou.count(1) + len(sentou) - sentou.count(1) - sentou.count(0))))

solve()

Submission status: Time Limit Exceeded

Solution code:
n, t = map(int, input().split())
a = list(map(int, input().split()))

s = set()
for i in range(n):
    for j in range(t):
        s.add(a[i]+j)

print(len(s))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
N, T= map(int, input().split())
t=list(map(int, input().split()))
end_t=T
for j in range (0,N):
  end_t=max(end_t, t[j]+T)
count=0
for s in range (0,end_t):#s秒時点で水で照るかっチェック
  for j in range (0,N):
    if t[j]<=s and s-T< t[j]:
      count+=1
      break
print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
N, T= map(int, input().split())
t=list(map(int, input().split()))
end_t=T
for j in range (0,N):
  end_t=max(end_t, t[j]+T)
R=[]
for i in range (0,end_t):
  R.append(0)
for s in range (0,end_t):#s秒時点で水で照るかっチェック
  for j in range (0,N):
    if t[j]<=s and s-T< t[j]:
      R[s]=1

count=0
for s in range (0, end_t):
  count+=R[s]
print(count)

Submission status: Time Limit Exceeded

Solution code:

N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []

d = set()
for i in range(N):
    d = d | set(range(a[i], a[i] + T))


print(len(d))

Submission status: Time Limit Exceeded

Solution code:
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []
"""
for i in range(N):
    set1 = set()
    for j in range(T):
        set1.add(a[i] + j)
    b.append(set1)
d = set()
for n in range(len(b)):
    d = d | b[n]
"""
d = set()
for i in range(N):
    d = d | set(range(a[i], a[i] + T))


print(len(d))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, T = map(int, raw_input().split())
    t = map(int, raw_input().split())
    c = t[-1] + T + 1
    a = [0 for _ in xrange(c)]
    for i in t:
        a[i] += 1
        a[i+T] -= 1

    count = 0
    for i in xrange(c):
        if(0 < i):
            a[i] += a[i - 1]
            if(a[i] != 0): count += 1

    if(a[0] != 0): count += 1
    print count
    return 0

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []
"""
for i in range(N):
    set1 = set()
    for j in range(T):
        set1.add(a[i] + j)
    b.append(set1)
d = set()
for n in range(len(b)):
    d = d | b[n]
"""
for i in range(N):

    b.append(range(a[i], a[i] + T))
d = set()
for n in range(len(b)):
    d = d | set(b[n])

print(len(d))

Submission status: Time Limit Exceeded

Solution code:
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))


b = []

for i in range(N):
    set1 = set()
    for j in range(T):
        set1.add(a[i] + j)
    b.append(set1)
d = set()
for n in range(len(b)):
    d = d | b[n]

print(len(d))

Submission status: Accepted

Solution code:
numbers = list(map(lambda x: int(x), input().split()))
nums = list(map(lambda x: int(x), input().split()))
t = numbers[1]

total = t
for i in range(1, len(nums)):
    check = nums[i] - nums[i - 1] 
    total += check if check <= t else t

print(total)

Submission status: Accepted

Solution code:
n,t=map(int,input().split())
T=list(map(int,input().split()))
ans=t
for i in range(n-1):
  ans += min(t,T[i+1]-T[i])
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 27 03:05:21 2020

@author: liang
"""

N ,T = map(int,input().split())

time = [int(x) for x in input().split()]

ans = 0
for i in range(N-1):
    ans += min(T, time[i+1]-time[i])
ans += T
print(ans)

Submission status: Accepted

Solution code:
N,T = map(int,input().split())
N_List = list(map(int,input().split()))

ans = 0
for i in range(1,N):
    ans += (T,N_List[i]-N_List[i-1])[N_List[i]-N_List[i-1]<=T]

ans += T
print(ans)

Submission status: Accepted

Solution code:
N,T=map(int,input().split())
t=list(map(int,input().split()))
ans = sum([min(t[i]-t[i-1], T) for i in range(1, N)])
print(ans+T)

Submission status: Accepted

Solution code:
n,t = map(int, input().split())
T = list(map(int, input().split()))

prev,now,ans = T[0],0,0

for i in range(n):
    if not i:
        continue
    now = T[i]
    if now-prev > t:
        ans += t
    else:
        ans += now-prev
    prev = now
ans += t
print(ans)

Submission status: Accepted

Solution code:
n, T = map(int, input().split())
tlst = list(map(int, input().split()))
ans = T
bef = tlst[0]
for t in tlst[1:]:
    ans += min(T, t - bef)
    bef = t
print(ans)

Submission status: Accepted

Solution code:
n,T = map(int, input().split())

t = list(map(int, input().split()))
ans = 0
for i, j in zip(t,t[1:]):
  ans += min(j-i,T)
print(ans + T)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if abs(t[i] - t[i+1]) < k:
    ans += abs(t[i] - t[i+1])
  else:
    ans += k
print(ans+k)

Submission status: Accepted

Solution code:
n, t = map(int, input().split())
L = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    ans += min(t, L[i+1] - L[i])
ans += t
print(ans)

Submission status: Accepted

Solution code:
N, T = map(int, input().split())
time = list(map(int, input().split()))

cnt = 0
for i in range(1,N):
    cnt += min(T, time[i] - time[i-1])
print(cnt+T)

Submission status: Accepted

Solution code:
n,T =map(int,input().split())
t = list(map(int, input().split()))
ans = T
for i in range(1,len(t)):
    if t[i] - t[i-1] >= T:
        ans += T
    else:
        ans += t[i] - t[i-1]
print(ans)

Submission status: Accepted

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))
Sum = T

for i in range(1, N):
    if t[i] - t[i - 1] < T:
        Sum += t[i] - t[i - 1]
    else:
        Sum += T

print(Sum)

Submission status: Accepted

Solution code:
N,T = map(int,input().split())
t = list(map(int,input().split()))
ans = 0

for i in range(N-1):
  if t[i+1]-t[i] > T:
    ans += T
  else:
    ans += t[i+1]-t[i]

print(T+ans)

Submission status: Accepted

Solution code:
n, t = map(int, input().split())
tl = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    ans += min(tl[i]-tl[i-1], t)
ans += t
print(ans)