#35227: 為什麼會一直TLE?


gokueric88@gmail.com (陳冠穎)

學校 : 不指定學校
編號 : 210599
來源 : [27.53.240.110]
最後登入時間 :
2024-09-26 15:37:57
b966. 3. 線段覆蓋長度 -- 2016年3月apcs | From: [111.249.159.31] | 發表日期 : 2023-05-17 17:10

count = int(input())
# print('\n')
# print(f'count: {count}')
collectRL = []


for _ in range(count):
collectRL.extend(list(map(int, input().split(" "))))
newCollect = collectRL
difference = []
first = []
for j in range(1, len(collectRL), 2):
# print(j)
difference.append(collectRL[j] - collectRL[j-1])
first.append(collectRL[j-1])
# print(difference)
newCollect.sort()
# print(newCollect)
test = [0] * newCollect[-1]

for i in range(count):
for j in range(difference[i]):
test[first[i] + j] = 1
# print(first)
result = 0
for n in range(len(test)):
if test[n] == 1:
result+=1
print(result)
 
ZeroJudge Forum