Skip to content

Instantly share code, notes, and snippets.

@Mons
Created May 16, 2018 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mons/15d5fc31a910dd3ef487f7e4ec53beed to your computer and use it in GitHub Desktop.
Save Mons/15d5fc31a910dd3ef487f7e4ec53beed to your computer and use it in GitHub Desktop.
#!/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