[Python] 소프티어 LV.2_GBC

szlee·2023년 11월 6일
0

알고리즘 PS

목록 보기
7/12

소프티어 LV.2_GBC

import sys


n, m = map(int, sys.stdin.readline().rstrip().split())
standard, test = [0]*101, [0]*101

sumi = 1
for _ in range(n): 
  h, v = map(int, sys.stdin.readline().rstrip().split())
  for i in range(sumi, sumi+h):
    standard[i] = v
  sumi += h
    
sumi = 1
for _ in range(m):
  th, tv = map(int, sys.stdin.readline().rstrip().split())
  for i in range(sumi, sumi+th):
    test[i] = tv
  sumi += th


result = 0
for ele in zip(standard, test):
  if ele[1] > ele[0]:
    result = max(result, abs(ele[0]-ele[1]))
print(result)
        
    

길이가 100까지로 정해져있으므로 배열 만들어 저장해서 값 비교하기.

Python
zip(): 데이터 엮기. 병렬처리. 길이가 짧은 데이터 만큼 가능
https://www.daleseo.com/python-zip/

profile
🌱

0개의 댓글