#!/usr/bin/perl use warnings; use strict; $\ = $/; srand( 1 ); my $n = 2e3; @_ = map int rand 1e5, 1 .. $n; print "@_[ 0 .. 3 ] ..."; my @max; push @max, ( sort { $b <=> $a } @_ )[ 0 ]; my @sums = @_; for my $i ( 1 .. $n - 1 ){ my $max = -~0; for my $j ( $i .. $n - 1 ){ # HOT-SPOT { $sums[ $j - $i ] += $_[ $j ]; $sums[ $j - $i ] > $max and $max = $sums[ $j - $i ]; # HOT-SPOT } } push @max, $max; } print "Finished"; #### ( $sums[ $j - $i ] += $_[ $j ] ) > $max and $max = $sums[ $j - $i ];