The Perl solution I submitted back in 2017:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my $test_count = <>; for my $test_case (1 .. $test_count) { my ($destination, $horse_count) = split ' ', <>; my $other_max = 0; for my $horse (1 .. $horse_count) { my ($position, $max_speed) = split ' ', <>; my $speed = ($destination - $position) / $max_speed; $other_max = $speed if $other_max < $speed; } say "Case #$test_case: ", $destination / $other_max; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The Perl solution I submitted back in 2017: