-
-
Save ilyabrin/a326de04c13e8e38a6b6 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
class Road < Object | |
attr_accessor :low_bound, | |
:high_bound, | |
:transport_count, | |
:road_id, | |
:counter | |
end | |
file = File.open('F:/input.txt', 'r') | |
i = 0 | |
road_count = file.readline.to_i; | |
arr = Array.new | |
r = nil | |
for i in (1..road_count) | |
line = file.readline.to_s | |
r = Road.new() | |
r.road_id = i | |
bound_arr = line.to_s.split(' ') | |
r.low_bound = bound_arr[0] | |
r.high_bound = bound_arr[1] | |
arr << r | |
end | |
file.readline(); | |
transp_str = file.readline().to_s + ' '; | |
start_pos = 0; | |
while start_pos < transp_str.length | |
# например, так | |
r.counter += 1 | |
arr[transp_str[start_pos..transp_str.index(' ', start_pos)].to_i].transport_count += 1 | |
start_pos = transp_str.index(' ', start_pos) + 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment