Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. inp = open("input.txt")
  2. out = open("output.txt", "w")
  3. pos, n = [int(x) for x in inp.readline().split()]
  4. a = []
  5. for i in range(n):
  6.   a.append([int(x) for x in inp.readline().split()][::-1])
  7. a.sort(reverse=True)
  8. for i in range(n):
  9.   if pos == a[i][1]:
  10.     pos += 1
  11.   elif pos == a[i][1] + 1:
  12.     pos -= 1
  13. out.write(str(pos))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement