Lang:Python2
Edit12345678910111213141516171819202122232425262728293031line1 = raw_input().split()n = int(line1[0])xy = [int(x)for x in line1[1:]]linent = []for i in range(n):linent.append([int(y) for y in raw_input().split()])linen = sorted(linent)x = xy[0];y = xy[1]R = []c = 1if xy in linen:print(1)else:if linen[0][0] <= x:x0 = linen[0][0]s = 0while True:R0t = []R0t = [r for r in linen[c-1:] if r[0]<=x0]R0 = sorted(R0t,key=lambda r:r[1])if len(R0) != 0:c += len(R0)x0 = R0[-1][1]R.append(x0)if x0>=y:print(len(R))breakelse:print(-1)breakelse: