long time no see. I was so busy with school tasks that I couldn't devote myself (excuse) It was a complete A and B. Moreover, I grew one pena each.
** Thoughts ** When $ m1> m2 $, it cannot be subtracted as it is, so 1 is fetched from $ h1 $.
h1, m1, h2, m2, k = map(int,input().split())
if m1 > m2:
m2 += 60
h2 -=1
ans_m = m2 - m1
else:
ans_m = m2 - m1
ans_h = h2 - h1
ans = 60 * ans_h + ans_m
print(ans-k)
I made a mistake in the order of subtraction and made 1WA. Mottainai
** Thoughts ** ~~ Hitachikon's nightmare comes back ~~, I'm not good at this kind of problem. It's best to set everything to D, but I didn't notice it, so I'm pushing it with an if statement.
t = list(input())
n = len(t)
if t[0] == '?':
if n > 1:
if t[1] == '?':
t[0] = 'P'
else:
t[0] = 'D'
else:
t[0] = 'D'
if t[-1] == '?':
t[-1] = 'D'
for i in range(1,n-1):
if t[i] == '?':
if t[i-1] == 'P':
t[i] = 'D'
else:
if t[i+1] == '?' or t[i+1] == 'D':
t[i] = 'P'
else:
t[i] = 'D'
ans = ''.join(t)
print(ans)
It was cool if I could solve C. I'm worried about ABC tomorrow. See you again, good night.
Recommended Posts