Problem:


Score : 100 points

Problem Statement

In this problem, we use the 24-hour clock.

Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)
He has decided to study for K consecutive minutes while he is up.
What is the length of the period in which he can start studying?

Constraints

0 \le H_1, H_2 \le 23

0 \le M_1, M_2 \le 59

The time H_1 : M_1 comes before the time H_2 : M_2.

K \ge 1

Takahashi is up for at least K minutes.

All values in input are integers (without leading zeros).

Input

Input is given from Standard Input in the following format:

H_1 M_1 H_2 M_2 K

Output

Print the length of the period in which he can start studying, as an integer.

Sample Input 1

10 0 15 0 30

Sample Output 1

270

Takahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.
It takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.

Sample Input 2

10 0 12 0 120

Sample Output 2

0

Takahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.



Sample input:
10 0 15 0 30


Sample output:
270

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys
import datetime

try:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

    while not (0 <= H1 or 0 <= M1 or 0 <= H2 or 0 <= M2):
        while not (H1 < 23 or M1 < 59 or H2 < 23 or M2 < 59):
            H1 = int(sys.stdin.readline())
            M1 = int(sys.stdin.readline())
            H2 = int(sys.stdin.readline())
            M2 = int(sys.stdin.readline())
            K = int(sys.stdin.readline())
        else:
            if M2 >= M1:
                a = (H2 - H1) * 60 + (M2 - M1)
                print(a - K)
            if M2 < M1:
                b = (H2 - H1) * 60 + (M1 - M2)
                print(b - K)
except:
    print("")

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys
import datetime

try:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

    while not (0 <= H1 < 23 or 0 <= M1 < 59 or 0 <= H2 < 23 or 0 <= M2 < 59):
        H1 = int(sys.stdin.readline())
        M1 = int(sys.stdin.readline())
        H2 = int(sys.stdin.readline())
        M2 = int(sys.stdin.readline())
        K = int(sys.stdin.readline())
    else:
        if M2 >= M1:
            a = (H2 - H1) * 60 + (M2 - M1)
            print(a - K)
        if M2 < M1:
            b = (H2 - H1) * 60 + (M1 - M2)
            print(b - K)
except:
    print("")

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys
import datetime

try:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())
    
    while not (H1 < 23 or M1 < 59 or H2 < 23 or M2 < 59):
        H1 = int(sys.stdin.readline())
        M1 = int(sys.stdin.readline())
        H2 = int(sys.stdin.readline())
        M2 = int(sys.stdin.readline())
        K = int(sys.stdin.readline())
    else:
        if M2 >= M1:
            a = (H2 - H1) * 60 + (M2 - M1)
            print(a - K)
        if M2 < M1:
            b = (H2 - H1) * 60 + (M1 - M2)
            print(b - K)
except:
    print("1")

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
ans=0
if(m1>0):
  ans+=(h2-(h1+1))*60
  ans+=m1
else:
  ans+=h2-h1
ans+=m2-k
print(ans)

Submission status: Wrong Answer

Solution code:
maxcount = -1
maxt = ''

def a(t):
  global maxcount
  global maxt
  j = t.find('?')
  if j == -1:
    n = t.count('PD') + t.count('D')
    if n > maxcount:
      maxcount = n
      maxt = t
  else:
    t = t[:j] + 'P' + t[j+1:]
    pc = a(t)
    t = t[:j] + 'D' + t[j+1:]
    dc = a(t)

t = input()
a(t)
print(maxt)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
ans=(h2-h1)*60
if(m1>0):
	ans+=(60-m1)
if(m2>0):
	ans+=m2
ans-=k
print(ans)

Submission status: Wrong Answer

Solution code:

h1, m1, h2, m2, k = map(int, input().split())

hour = (h2-h1)
minu = (abs(m2-m1))

time = hour * 60 + minu - k

if(time >= 0):
  print(time)
else:
  print("0")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

a, b, c, d, e = map(int, input().split())

print((c-a)*60-(d-b)-e)

Submission status: Wrong Answer

Solution code:

h1, m1, h2, m2, k = map(int, input().split())

hour = (h2-h1)
minu = (abs(m2-m1))

print(hour * 60 + minu - k)

Submission status: Wrong Answer

Solution code:
T = input()
t = T.count("?")
num =[]
for i in range(0,t+1):
    st = T.replace("?" , "D", i)
    for n in range(0,t+1):
        ste = st.replace("?","P",n)
        for q in range(0,t+1):
            stes = ste.replace("?","D",q)
            num.append(stes)
            print(num)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int,input().split())

h = abs(h1-h2)
m = abs(m1-m2)

ans = h*60+m
ans = ans-k

print(ans)

Submission status: Wrong Answer

Solution code:
T = input()
t = T.count("?")
num =[]
for i in range(0,t+1):
    st = T.replace("?" , "D", i)
    for n in range(0,t+1):
        ste = st.replace("?","P",n)
        for q in range(0,t+1):
            stes = ste.replace("?","D",q)
            num.append(stes)
            print(num)
s = stes.count("DD")
f = stes.count("PD")
ans = s + f
print(ans)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())
 
tmp = K
if (M1 < M2):
  H = H2 - H1 - 1
  M = M1 - M2
  if M < 0:
    M = 60 - M
    
else:
  H = H2 - H1
  M = M2 - M1
 
T = H * 60 + M
 
ans = 0
while T > tmp:
  T = T - K
  ans += K
 
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil, floor

h1, m1, h2, m2, k = map(int, input().split())

diff = (h2-h1)*60 + (m2-m1) 

if diff % k == 0:
    print('%d' % max(0, diff-k))
else:
    print('%d' % int(max(0, k*(floor(diff/k)))))

Submission status: Wrong Answer

Solution code:
print("aaa")

Submission status: Wrong Answer

Solution code:
#A - Study Scheduling

def answ():
    h1, m1, h2,m2,k = map(int, input().split())
    if h1 > h2:
        h2 +=24
    h = h2 - h1
    m = m2 - m1
    if m < 0:
        m = m + 60
        h = h - 1
    time = h*60 + m 
    return time - k
answ()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys
import datetime

H1 = sys.stdin.readline()
M1 = sys.stdin.readline()
H2 = sys.stdin.readline()
M2 = sys.stdin.readline()
K = sys.stdin.readline()


# while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
#     H1 = sys.stdin.readline()
#     M1 = sys.stdin.readline()
#     H2 = sys.stdin.readline()
#     M2 = sys.stdin.readline()
#     K = sys.stdin.readline()

if M2 > M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

t = input()

t_update = ""
for i in t:
    if i == "?":
        i = "D"
    t_update += i
print(t_update)

Submission status: Wrong Answer

Solution code:
import sys
h1 = sys.stdin.readline()
m1 = sys.stdin.readline()
h2 = sys.stdin.readline()
m2 = sys.stdin.readline()
k = sys.stdin.readline()

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=(int(x)for x in input().split())
x=(c-a)*60
z1=b-d
z2=abs(z1)
z3=60-z2
if z3>=30:
    y=x-e+30
if z3<30:
    y=x-e

if y<e:
    print("0")
else:
    print(y)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

t = input()

t_update = ""
for i in t[1:]:
    if i == "?":
        i = "D"
    t_update += i
print(t_update)

Submission status: Wrong Answer

Solution code:
#A - Study Scheduling

def answ():
    h1, m1, h2,m2,k = map(int, input().split())
    h = h2 - h1
    m = m2 - m1
    if m < 0:
        m = m + 60
        h = h - 1
    time = h*60 + m 
    return time - k
answ()

Submission status: Wrong Answer

Solution code:
from math import ceil, floor

h1, m1, h2, m2, k = map(int, input().split())

diff = (int)(h2-h1)*60 + (m2-m1) if m2 >=m1 else (h2-h1)*60 + 60 - (m2-m1)

if diff % k == 0:
    print('%d' % max(0, k*(ceil(diff/k)-1)))
else:
    print('%d' % max(0, k*(floor(diff/k))))

Submission status: Wrong Answer

Solution code:
from math import ceil, floor

h1, m1, h2, m2, k = map(int, input().split())

diff = (int)(h2-h1)*60 + (m2-m1) if m2 >=m1 else 60 - (m2-m1)

if diff % k == 0:
    print('%d' % max(0, k*(ceil(diff/k)-1)))
else:
    print('%d' % max(0, k*(floor(diff/k))))

Submission status: Wrong Answer

Solution code:
abc = [int(e) for e in input().split()]

H1 = abc[0]
M1 = abc[1]
H2 = abc[2]
M2 = abc[3]
K = abc[4]

start_time = H1*60 + M1
end_time = H2*60 + M2
if end_time > start_time:
    valid_time = end_time - start_time
elif start_time > end_time:
    valid_time = (end_time+24*60) - start_time
else:
    valid_time = 0

if valid_time % K == 0:
    valid_time = valid_time - 1

execution_time = valid_time // K

ans = execution_time * K

print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

t = input()
t_update = t[0]
for i in t[1:]:
    if i == "?":
        i = "D"
    t_update += i
print(t_update)

Submission status: Wrong Answer

Solution code:
abc = [int(e) for e in input().split()]

H1 = abc[0]
M1 = abc[1]
H2 = abc[2]
M2 = abc[3]
K = abc[4]

start_time = H1 + M1/60
end_time = H2 + M2/60
valid_time = (end_time-start_time) * 60

if valid_time % K == 0:
    valid_time = valid_time - 1

execution_time = valid_time // K

ans = execution_time * K

print(int(ans))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=(int(x)for x in input().split())
x=(c-a)*60
z1=b-d
z2=abs(z1)
z3=60-z2
if z3>=30:
    y=x-e
if z3<30:
    y=x-e+30

if y<e:
    print("0")
else:
    print(y)

Submission status: Wrong Answer

Solution code:
H = input().split()
sdy =0
if int(H[2]) >= int(H[0]):
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
else:
  H[2] = (int(H[2])+24)
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
if int(sdy) < 0:
  sdy = 0
print(sdy)

Submission status: Wrong Answer

Solution code:
abc = [int(e) for e in input().split()]

H1 = abc[0]
M1 = abc[1]
H2 = abc[2]
M2 = abc[3]
K = abc[4]

start_time = H1 + M1/60
end_time = H2 + M2/60
valid_time = (end_time-start_time) * 60
valid_time = valid_time - 1

execution_time = valid_time // K

ans = execution_time * K

print(int(ans))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

time = (h2 - h1) * 60 + (m2 - m1) - 1

import math

try:
    print(math.floor(time // k) * k)
except:
    print(0)

Submission status: Wrong Answer

Solution code:
abc = [int(e) for e in input().split()]

H1 = abc[0]
M1 = abc[1]
H2 = abc[2]
M2 = abc[3]
K = abc[4]

start_time = H1 + M1/60
end_time = H2 + M2/60
valid_time = (end_time-start_time) * 60
valid_time = valid_time - 1

execution_time = valid_time // K

ans = execution_time * K

print(ans)

Submission status: Wrong Answer

Solution code:
H = input().split()
sdy =0
if int(H[2]) > int(H[0]):
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
else:
  H[2] = (int(H[2])+24)
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
print(sdy)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())

h = H2 - H1
m = M2 - M1
s = 0
if h > 0:
    s = h * 60 + m


# print(s)1
if s - K > 0:
    s = s - K
else:
    s = 0
print(s)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = list(map(int,input().split()))


minutes = H2*60-H1*60+M1-M2 -K
print(minutes)

Submission status: Wrong Answer

Solution code:
HMK = list(map(int, input().split()))
H1 = HMK[0]
M1 = HMK[1]
H2 = HMK[2]
M2 = HMK[3]
K = HMK[4]
if H2 < H1:
	H2 += 24
ans = ((H2 - H1) * 60 + (M1 + M2)) - K
print(ans)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = list(map(int, input().split()))
Length = abs(H1 - H2)*60 - K
print(Length)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
H = (h2-h1)*60
M = abs(m1-m2)
ans = H-M-k
print(ans)

Submission status: Wrong Answer

Solution code:
H = input().split()
sdy =0
if int(H[2]) > int(H[0]):
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
else:
  H[2] = (int(H[2])+24)
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
print(sdy)

Submission status: Wrong Answer

Solution code:
HMK = list(map(int, input().split()))
H1 = HMK[0]
M1 = HMK[1]
H2 = HMK[2]
M2 = HMK[3]
K = HMK[4]
ans = ((H2 - H1) * 60 + (M1 + M2)) - K
print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

H = (h2-h1)*60
M = abs(m1-m2)

print(H-M-k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int,input().split())
 
h=h2 - h1
if h <= 0:
    h = 24+h
m=m2 - m1
 
du=h*60+m-k
 
print(du)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
minute=(h2-h1)*60+(m2-m1)-2
t=minute//k
print(t*k)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
t = H2 - H1
t1 = abs(M2 - M1)
l = t*60  + t1
if K < l/2:
  print(l-K)
elif K > l/2:
  print(K)
elif K == l:
  print(0)
else:
  pass

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
minute=(h2-h1)*60+(m2-m1)-2
t=minute//k
#print(t*k)
if minute<k:
    print(0)
else:
    print(t*k)

Submission status: Wrong Answer

Solution code:
T = list(input())

if T[0] == '?':
    T[0] = 'P'

for i in range(1, len(T)-1):
    if T[i] == '?':
        if T[i-1] == 'P':
            T[i] = 'D'
        elif T[i+1] == 'D':
            T[i] = 'P'
        elif T[i+1] == '?':
            T[i] = 'P'
        else:
            T[i] = 'D'

if T[-1] == '?':
    T[-1] = 'D'

print(''.join(T))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

h1h2 = (h2-h1)*60
m1m2 = abs(m1-m2)

print(h1h2-m1m2-k)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int,input().split())
import math
p=(H2-H1)*60
if M2-M1<0:
    a=M2-M1+60
    p-=60
else:
    a=M2-M1
p+=a
time = K*math.floor(p/K)
if p%K==0:
    time=time-K
print(time)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

h1h2 = abs((h1-h2)*60)
m1m2 = abs(m1-m2)

print(h1h2-m1m2-k)

Submission status: Wrong Answer

Solution code:
T = list(str(input()))

for i in range(len(T)):
    if T[i] == '?':
        if T[i - 1] == 'P':
            T[i] = 'D'
        elif T[i + 1] == '?':
            T[i] = 'P'
            T[i + 1] = 'D'
            i= i+1
        else:
            T[i] = 'D'
        

TL=''.join(T)
print(TL)

Submission status: Wrong Answer

Solution code:
H = input().split()
sdy =0
if H[2] > H[0]:
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
else:
  H[2] = int(H[2])+24
sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
print(sdy)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int,input().split())
import math
p=(H2-H1)*60
if M1-M2<0:
    a=M1-M2+60
    p-=60
else:
    a=M1-M2
p+=a
time = K*math.floor(p/K)
if p%K==0:
    time=time-K
print(time)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k =(int(x) for x in input().split())  
 
hrtom= (h2-h1)
 
if (m2-m1 < 0) and (h2-h1 >=0) : 
    min = (h2-h1)*60 - (m2-m1) - k
    print(min)
    
elif (m2-m1 >= 0) and (h2-h1 >=0 ):
    min = (h2-h1)*60 + (m2-m1) - k 
    print(min)

elif (m2-m1 < 0) and (h2-h1 <=0) :
    min = (24-h1+h2)*60 - (m2-m1) -k 
    print(min) 
    
elif (m2-m1 >= 0) and (h2-h1 <=0) :
    min = (24-h1+h2)*60 + (m2-m1) -k 
    print(min) 
    
else:
    print('0')

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

time = 60*h2+m2 - 60*h1+m1
if time >= k:
  print(time-k)
else:
  print(60*24+time-k)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=(int(x)for x in input().split())
x=(c-a)*60
z1=b-d
z2=abs(z1)
if z2>=30:
    y=x-e+30
if z2<30:
    y=x-e

if y<e:
    print("0")
else:
    print(y)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
t = H2 - H1
t1 = abs(M2 - M1)
l = t*60  + t1
if K < l/2:
  print(l-K)
elif K > l/2:
  print(K)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3

import math

h1, m1, h2, m2, k = map(int, input().split())

if h1 > h2:
    h2 += 24

if m2 < m1:
    h2 -= 1
    m2 = 60

allMin = (h2 - h1) * 60 + (m2 - m1)

res = allMin - k
if res < 0:
    res = 0

print(res)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
t = H2 - H1
t1 = abs(M2 - M1)
l = t*60  + t1
if K < l/2:
  print(l-K)
elif K > l/2:
  print(K-l)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3

import math

h1, m1, h2, m2, k = map(int, input().split())

if m2 < m1:
    h2 -= 1
    m2 = 60

if h1 > h2:
    h2 += 24

allMin = (h2 - h1) * 60 + (m2 - m1)

res = allMin - k
if res < 0:
    res = 0

print(res)

Submission status: Wrong Answer

Solution code:
h,m,a,b,k=map(int,input().split())
m_to_hour = m /60
b_to_hour = b /60
h_hour = h + m_to_hour
a_hour = a + b_to_hour
re = a_hour - h_hour
to_min =( re )*60
print(int(to_min-k))

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k =(int(x) for x in input().split())  
 
hrtom= (h2-h1)
 
if (m2-m1 < 0) and (h2-h1 >=0) : 
    min = (h2-h1)*60 - (m2-m1) - k
    print(min)
    
elif (m2-m1 >= 0) and (h2-h1 >=0 ):
    min = (h2-h1)*60 + (m2-m1) - k 
    print(min)

elif (m2-m1 < 0) and (h2-h1) <=0 :
    min = (24-h1+h2)*60 - (m2-m1) -k 
    print(min) 
    
elif (m2-m1 >= 0) and (h2-h1) <=0 :
    min = (24-h1+h2)*60 + (m2-m1) -k 
    print(min)

Submission status: Wrong Answer

Solution code:
def main():
    T = input()
    # ?D -> PD
    # ?P -> DP
    # ?? -> PD 
    # ??? -> PDD

    T = T.replace("?D", "PD")
    T = T.replace("?P", "DP")
    T = T.replace("??", "PD")
    T = T.replace("?", "D")

                    
    print(T)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if i==0 and len(s)==1 and s_[i]=='?':
    s_[i]='D'
  elif i==0 and s_[i]=='?' and s_[i+1]=='D':
      s_[i]='P'
  elif i==0 and s_[i]=='?' and s_[i+1]=='P':
      s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='P':
    s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='D':
    if s_[i+1]=='D' or s_[i+1]=='?':
      s_[i]='P'
      s_[i+1]='D'
    else:
      s_[i]='D'
    
S = "".join(s_)
print(S)

Submission status: Wrong Answer

Solution code:
H = input().split()
if H[0] > H[2]:
  H[2] = int(H[2])+24
sdy =0
sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 +int(H[1]) - int(H[4])
print(sdy)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
t = H2 - H1
t1 = abs(M2 - M1)
l = t*60  + t1
if K < l:
  print(l-K)
elif K == l:
  print(0)

Submission status: Wrong Answer

Solution code:

import datetime
h1, m1, h2, m2, k = map(int, input().split())
one = datetime.timedelta(hours=h1, minutes=m1)
two = datetime.timedelta(hours=h2, minutes=m2)
study = datetime.timedelta(minutes=k)

diff_one_two_seconds = (two.total_seconds() - one.total_seconds()) / 60
study_seconds = study.total_seconds()/60
print(diff_one_two_seconds - study_seconds)

Submission status: Wrong Answer

Solution code:
#答え
T=input()

#考えられる要素数total
total=2**T.count("?")
#?の個数
num=T.count("?")

ans=0
ans_str=""
for i in range(total):
    T_trans=""
    #変換後のT
    trans=[]
    #このリストにそって、?をPかDに変換する
    #ここで1がP、0がDとし、格納していく
    ptn = bin(i)[2:].rjust(num, "0")
    for j in range(num):
        if ptn[j]==1:
            trans.append(1)
        else:
            trans.append(0)
    
    for k in T:
        if k=="?":
            if trans[0]==1:
                T_trans+="P"
                del trans[0]
            else:
                T_trans+="D"
                del trans[0]
        else:
            T_trans+=k
    
    n=T_trans.count("D")+T_trans.count("PD")
    if ans<=n:
        ans_str=T_trans
        ans=n
    
print(ans_str)

Submission status: Wrong Answer

Solution code:
from sys import stdin

h1, m1, h2, m2, k = [int(x) for x in stdin.readline().rstrip().split()]

allMin1 = h1 * 60
allMin2 = h2 * 60



diff = (allMin2 - allMin1)
sec = m2 - m1

diff -= sec

if diff < 0 :
	diff += 24 * 60

ans = diff - k

if ans >= 0 :
	print(ans)
else :
	print(0)

Submission status: Wrong Answer

Solution code:
L=list(map(int,input().split()))
if L[0] > L[2]:
	A=60*L[0]+L[1]
	B=60*(L[2]+24)+L[3]
else:
	A=60*L[0]+L[1]
	B=60*L[2]+L[3]

if B-A <= L[4]:
	print("0")
elif (B-A)%L[4]==0:
	print(str(((B-A)-L[4])))
else:
	print(str(L[4]*round((B-A)//L[4])))

Submission status: Wrong Answer

Solution code:
t = input()
ans=t.replace('?D','PD')
ans=ans.replace('P?','PD')
ans=ans.replace('??','PD')
ans=ans.replace('?','D')
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    H1, M1, H2, M2, K = read_values()
    m1 = H1 * 60 + M1
    m2 = H2 * 60 + M2 - 1

    m = m2 - m1 
    if m < 0:
        m += 60 * 24
    print((m // K) * K)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
H = list(map(int,input().split()))

h = H[2]-H[0]
m = H[3]-H[1]

if h < 0:
    h = h + 24

if m < 0:
    h -= 1
    m *= -1

mini = h*60 + m - H[4]

if mini < 0:
    mini = 24*60 + mini

print(mini)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k =(int(x) for x in input().split())  
 
hrtom= (h2-h1)
 
if (m2-m1 < 0) and (h2-h1 >=0) : 
    min = (h2-h1)*60 - (m2-m1) - k
    print(min)
    
elif (m2-m1 >= 0) and (h2-h1 >=0 ):
    min = (h2-h1)*60 + (m2-m1) - k 
    print(min)

elif (m2-m1 < 0) and (h2-h1) <=0 :
    min = (h1+h2-23)*60 - (m2-m1) -k 
    print(min) 
    
elif (m2-m1 >= 0) and (h2-h1) <=0 :
    min = (h1+h2-23)*60 +(m2-m1) -k 
    print(min) 
    
else:
    print('0')

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    H1, M1, H2, M2, K = read_values()
    m1 = H1 * 60 + M1
    m2 = H2 * 60 + M2 - 1

    m = m2 - m1 
    print((m // K) * K)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = [int(s) for s in input().split()]
if H2 < H1:
    H2 += 24
elif H2 == H1 and M1 > M2:
    H2 += 24
print(int(H2 * 60 + M2 - H1 * 60 + M1 - K))

Submission status: Wrong Answer

Solution code:
okiji,okihun,neji,nehun,benji=map(int,input().split())
if neji>okiji:
    print((neji*60+nehun)-(okiji*60+okihun)-benji)
else:
    print((neji*60+nehun)+(okiji*60+okihun)-benji)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=(int(x)for x in input().split())
x=(c-a)*60
z1=(b-d)
z2=abs(z1)
y=x-e+z2

if y<e: 
    print("0")
else:
    print(y)

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    H1, M1, H2, M2, K = read_values()
    m = (H2 - H1) * 60 + (M2 - M1) - 1
    print(m // K * K)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
H = list(map(int,input().split()))

h = H[2]-H[0]
m = H[3]-H[1]

if h < 0:
    h = h + 24

if m < 0:
    h -= 1
    m *= -1

mini = h*60 + m - H[4]

if mini < 0:
    mini = 24*60 -mini

print(mini)

Submission status: Wrong Answer

Solution code:
t=input()
result=''
for i in range(len(t)-1):
    if t[i]=='?':
        try:
            if result[i-1]=='P':
                result+='D'
            else:
                result+='P'
        except:
            if  t[i+1]=='P':
                result+='D'
            else:
                result+='P'
    else:
        result+=t[i]
print(result+'D')

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = [int(i) for i in input().split()]

awake = 60*h2+m2 - 60*h1+m1
if awake >= 0:
  print(awake-k)
else:
  print(60*24+awake-k)

Submission status: Wrong Answer

Solution code:
from sys import stdin

h1, m1, h2, m2, k = [int(x) for x in stdin.readline().rstrip().split()]

allMin1 = h1 * 60
allMin2 = h2 * 60



diff = (allMin2 - allMin1)
sec = m2 - m1
if sec < 0 :
	sec += 60
	
diff = diff - sec

if diff < 0 :
	diff += 24 * 60

ans = diff - k

if ans >= 0 :
	print(ans)
else :
	print(0)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

H1, M1, H2, M2, K = read_ints()


minu = H2 * 60 + M2 - (H1 * 60 + M1)

print((minu - 1) // K * K)

Submission status: Wrong Answer

Solution code:
h,m,H,M,k = map(int,input().split())
tmp = (60*H+M)-(60*h+m)-0.0000001
a = tmp//k
ans = k*a
print(int(ans))

Submission status: Wrong Answer

Solution code:
L=list(map(int,input().split()))
if L[0] > L[2]:
	A=60*L[0]+L[1]
	B=60*(L[2]+24)+L[3]
else:
	A=60*L[0]+L[1]
	B=60*L[2]+L[3]

if B-A <= L[4]:
	print("0")
elif (B-A)%L[4]==0:
	print(str(((B-A)-L[4])))
else:
	print(str(round((B-A)//L[4])))

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k =(int(x) for x in input().split())  
 
hrtom= (h2-h1)
 
if (m2-m1 < 0) and (h2-h1 >=0) : 
    min = (h2-h1)*60 - (m2-m1) - k
    print(min)
    
elif (m2-m1 >= 0) and (h2-h1 >=0 ):
    min = (h2-h1)*60 + (m2-m1) - k 
    print(min)

elif (h2-h1) <=0 :
    min = (h1-h2)*60 +(m2-m1) -k 
    print(min) 
else:
    print('0')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum


def çözmek():
    h, m, H, M, K = map(int, input().split(" "))
    if H:
        H = H * 60
    if h: 
        h = h * 60
    res = H + M - K - h + m
    print(res)
if __name__ == "__main__":
    çözmek()

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=(int(x)for x in input().split())
x=(c-a)*60
z=-(b-d)
y=x-e+z

if y<e: 
    print("0")
else:
    print(y)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=input().split()

h1 = int(h1)
m1 = int(m1)
h2 = int(h2)
m2 = int(m2)
k = int(k)

if h1 > h2:
  h2 += 24
  
h = h2 - h1
hm = h * 60

print(hm + m1 - m2 - k)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int,input().split())
print(h2*60+m2 - h1*60+m1 - k)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int,input().split())
t = (h2-h1)*60+(m2-m1+60)%60
print(t-k)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K=map(int,input().split())
if M1>M2:
    print(max((H2-H1-1)*60+(M1-M2)-K,0))
else:
    print(max((H2-H1)*60+(M2-M1)-K,0))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2 ,k = map(int, input().split())
t1 = h1*60 + m2
t2 = h2*60 + m2 - k
ans = (t2-t1)%1440
print(ans)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=input().split()

h1 = int(h1)
m1 = int(m1)
h2 = int(h2)
m2 = int(m2)
k = int(k)

if h1 > h2:
  h2 += 24
  
h = h1 - h2
hm = h * 60

print(hm + m1 - m2 - k)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())

tmp = K
if (M1 < M2):
  H = H2 - H1 - 1
  M = M1 - M2
  if M < 0:
    M = 60 - M
    
else:
  H = H2 - H1
  M = M2 - M1

T = H * 60 + M

ans = 0
while T > tmp:
  T = T - K
  ans += K

print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))
if m2 < m1:
    th = h2 - h1 - m1/60
    tm = m2 -m1 % 60
else:
    tm = m2 - m1
    th = h2 -h1
if k > (th*60 + tm):
    print (0)
else:
    print(th*60 + tm - k)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

list = input().split()

m1 = int(list[0])*60 + int(list[1])
m2 = int(list[2])*60 + int(list[3])
#print(m1,m2)
    
ans = m2 - m1
if ans%int(list[4]) == 0:
    print(int(ans/int(list[4])-1)*int(list[4]))
else:
    print(int(ans/int(list[4]))*int(list[4]))

Submission status: Wrong Answer

Solution code:
li = list(map(int,input().split()))
h1, m1, h2, m2, k = li
life_time = (h2 - h1)*60 + (m2 - m1)
time = life_time - k # 分

Submission status: Wrong Answer

Solution code:
import time
import datetime
from datetime import timedelta
H1,M1,H2,M2,K=map(int,input().split())


delta1=timedelta(minutes=M1,hours=H1)
delta2=timedelta(minutes=M2,hours=H2)

delta=delta2-delta1
delta_minutes=delta.total_seconds()/60
if delta_minutes>K:
  print(delta_minutes-K)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = list(map(int, input().split()))
time = (H2 - H1) * 60 + M2 - M1
study = K
while study < time:
    study += K
print(study - K)

Submission status: Wrong Answer

Solution code:
H_1, M_1, H_2, M_2, K = map(int, input().split())

time =(H_2 * 60 + M_2)-(H_1 * 60 + M_1)

a = time // K

if a == 0 :
    print(0)
    exit(0)

if time % K == 0:
    a = a-1

print(a*K)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum


def çözmek():
    h, m, H, M, K = map(int, input().split(" "))
    res = (H * 60) + M - K - (h * 60) + m
    print(res)
if __name__ == "__main__":
    çözmek()

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

if m2 >= m1:
	time = (h2 - h1) * 60 + abs(m1 - m2) - k
else:
	time = abs(m1 - m2) - k

print(time)