“Time Limit Exceeded.”是什么鬼啊?

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

superAMei @ 2023-07-23 14:08:19

a = list(input().split())
b = []
c = int(a[0])+1
d = []
for i in range(int(a[1])):
    b.append(input().split())
for x in range(1,c):
    for y in b:
        if(x >= int(y[0]) and x <= int(y[1])):
            if(x not in d):
                c -= 1
                d.append(int(x))
print(str(c))

我感觉运行得挺快的啊!


by AfterFullStop @ 2023-07-23 14:10:46

@superAMei python本来就很慢,算法竞赛的题最好不用python

样例为了方便调试,会把数据量弄的比较小,因此你自然觉得快


by juruo_zxt @ 2023-07-23 14:11:26

时间"充足"。


by srds_cbddl @ 2023-07-23 14:19:23

@superAMei 可以尝试使用 PyPy3 提交。


|