Created
May 16, 2018 18:54
-
-
Save Mons/15d5fc31a910dd3ef487f7e4ec53beed 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
#!/usr/bin/env perl | |
use 5.016; | |
use integer; | |
my $n = <>; | |
local $/ = " "; | |
$, = " "; | |
my @bottom; | |
while (<>) { | |
if (@bottom < 5) { | |
push @bottom, 0+$_; | |
@bottom = sort { $b <=> $a } @bottom; | |
} | |
elsif ( $_ < $bottom[0] ) { | |
push @bottom, 0+$_; | |
@bottom = sort { $b <=> $a } @bottom; | |
pop @bottom; | |
} | |
say @bottom; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment