|
|
вернуться в форумHow to do faster I/O using Python, similar to scanf in C++? #!/usr/bin/env python from sys import stdin n = int(stdin.readline()) p = [0] * n for i in xrange(n): p[i] = int(stdin.readline()) def chk(s, p, n): left = 0 right = n - 1 while left <= right: mid = (left + right) / 2 if s > p[mid]: left = mid + 1 elif s < p[mid]: right = mid - 1 else: return True return False c = 0 m = int(stdin.readline()) for i in xrange(m): s = int(stdin.readline()) if chk(s, p, n): c += 1 print c The above code is TL8. |
|
|