개발자 톡

연습문제 톡 GBC

파이썬 8번 테케 ㅠㅠ

등록일
2024-02-01 14:58:38
조회수
313
작성자
yerin1198
from collections import defaultdict
import sys


N,M=map(int,input().split())
speed=defaultdict(int)


arr=[]
test=[]


cur=0
for i in range(N):
    a,b=map(int,input().split())
    speed[i]=b
    arr.append((cur,cur+a))
    cur+=a


for i in range(M):
    a,b=map(int,input().split())
    test.append((a,b))


ans=0
cur=0
for ta,tb in test:
    start,end=cur,cur+ta
    for i in range(len(arr)):
        a,b=arr[i]
        if a==start or b==end:
            if speed[i]<tb:
                ans=max(ans,tb-speed[i])
        elif a<start and start<b:
            if speed[i]<tb:
                ans=max(ans,tb-speed[i]) 
        elif a<end and end<b:
            if speed[i]<tb:
                ans=max(ans,tb-speed[i])    
    cur+=ta


print(ans)
            

8번 테케만 틀리는데 어느 부분이 잘못되었는지 알려주실 수 있나용 ㅜㅜ

#gbc

이 카테고리의 톡 더보기