Created
September 27, 2017 08:40
-
-
Save whatalnk/639628f13d478c8628e2f54d676d5187 to your computer and use it in GitHub Desktop.
AtCoder ABC #024 C. 民族大移動
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
n, d, k = gets.chomp.split(" ").map(&:to_i) | |
lr = [] | |
d.times do | |
l, r = gets.chomp.split(" ").map(&:to_i) | |
lr << [l, r] | |
end | |
k.times do | |
s, t = gets.chomp.split(" ").map(&:to_i) | |
curr = s | |
ans = 0 | |
lr.each do |l, r| | |
if l <= curr && r >= curr then | |
if l <= t && r >= t then | |
ans += 1 | |
break | |
end | |
if (t - l).abs < (t - r).abs then | |
curr = l | |
else | |
curr = r | |
end | |
end | |
ans += 1 | |
end | |
puts ans | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment