Skip to content

Instantly share code, notes, and snippets.

@vikhyat
Created December 10, 2014 04:34
Show Gist options
  • Save vikhyat/24ba63bc8bf4ab0f6f8d to your computer and use it in GitHub Desktop.
Save vikhyat/24ba63bc8bf4ab0f6f8d to your computer and use it in GitHub Desktop.
a, b = gets.split.map {|x| x.to_i }
data = []
a.times do
data << gets.split.map {|x| x.to_i }
end
gets.to_i.times do
px, py, qx, qy = gets.split.map {|x| x.to_i }
sum = 0
for x in (px-1)..(qx-1)
for y in (py-1)..(qy-1)
sum += data[x][y]
end
end
puts sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment