0 0 0
2
2 86400
3
이면 24 0 0 이 출력되네요.
12840번 - 창용이의 시계
혹시 시간초과가 나는데 줄일만한 부분이 있을까요?...
h,m,s=map(int,input().split())
N=int(input())
for i in range(N):
T=list(map(int,input().split()))
if T[0]==1:
c=T[1]
H=c//3600
M=(c%3600)//60
S=(c%3600)%60
s=s+S
if s>=60:
m+=1
s-=60
m=m+M
if m>=60:
h+=1
m-=60
h=h+H
if h>=24:
h=h%24
elif T[0]==2:
c=T[1]
H=c//3600
M=(c%3600)//60
S=(c%3600)%60
s=s-S
if s<0:
m-=1
s+=60
m=m-M
if m<0:
h-=1
m+=60
h=h-H
if h<0:
t=abs(h)%24
if t==0:
h=0
else:
h=h+24*((abs(h)//24)+1)
else:
print(h,m,s)
제가 코드를 바꿔 봤는데 이렇게 하면 틀렸다고 나오네요...
잘못된 부분이 제가 반례로 찾아봤을때는 안보이네요...
정말 죄송하지만 한번 더 봐주실수 있으실까요..
input=__import__('sys').stdin.readline
h,m,s=map(int,input().split())
N=int(input())
now = 3600*h+60*m+s
for i in range(N):
T=list(map(int,input().split()))
if T[0]==3:
print(h,m,s)
else:
c=T[1]
if T[0]==1:
now=now+c
h=now//3600
m=(now%3600)//60
s=now%60
if h>=24:
h=h%24
else:
now=now-(c%86400)
if now<0:
now+=86400
h=now//3600
m=(now%3600)//60
s=now%60
감사합니다 ㅠㅠ 덕분에 해결했어요 ~~!!
댓글을 작성하려면 로그인해야 합니다.
donguk6634 2년 전
예제는 다 맞게 나오는데 반례좀 알려주십쇼