暴力求解TLE了。。。

P1047 [NOIP2005 普及组] 校门外的树

Py_PVZ @ 2023-12-03 10:32:20

暴力求解TLE了怎么办aaa(只拿了40分)

a = input().split()
l = int(a[0])
m = int(a[1])
num = []
remove = []
for i in range(l+1):
    num.append(i)
for j in range(m):
    b = input().split()
    start = int(b[0])
    end = int(b[1])
    for n in range(end-start+1):
        remove.append(start+n)
    for q in remove:
        if q in num:
            num.remove(q)
    remove = []
print(len(num))

by HuangTian @ 2023-12-03 10:34:49

换成PyPy3语言交试试?


by HuangTian @ 2023-12-03 10:35:10

@Py_PVZ


by Py_PVZ @ 2023-12-03 10:36:16

@FUCKCCF1 谢谢,我去试试


by Py_PVZ @ 2023-12-03 10:37:15

@FUCKCCF1 谢谢大佬,AC了


|