Created
December 10, 2014 04:34
-
-
Save vikhyat/24ba63bc8bf4ab0f6f8d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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