Created
July 10, 2017 16:16
-
-
Save IKKO-Ohta/f6257f8238f2469fd9635d8c4d8020a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nums = [int(x) for x in input().split()] | |
N,D,K = nums[0],nums[1],nums[2] | |
line = [] | |
for i in range(D): | |
nums = [int(x) for x in input().split()] | |
line.append(tuple(nums)) | |
for i in range(K): | |
nums = [int(x) for x in input().split()] | |
S,T = nums[0],nums[1] | |
ans = 1 | |
for elem in line: | |
if not (elem[0] <= S <= elem[1]): ans += 1; continue # 動けない | |
if S < T: # 目的地が前方方向 | |
if S <= T <= elem[1]: break | |
else: | |
S = elem[1]; ans += 1 | |
else: # 目的地は逆方向 | |
if elem[0] <= T <= S: break | |
else: | |
S = elem[0]; ans += 1 | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment