#!/usr/bin/perl

use 5.038.2;

# my $ancho = 12;
# my $largo = 150;

my @TVOL = qw (0.3 0.4 0.5 0.75 1 2);    # millons of barreles (not to exists, but you
                                         # get that large numbers are hard)

my @maxvol;
@maxvol = (-9e99) x scalar(@TVOL);
while (1){

    for (my $lote = 10; $lote <= 50; $lote += 5){      # lote de barcos del estrecho que puede
	                                               # existir o no, no soy un satélite
	my $vol = 0;
	my $sum = 0;
	my @n;
	for (0 .. scalar(@TVOL)-1){
	    
	    $n[$_] = int (rand()* ($lote -$sum)) // 0;   # número de barcos
	    
	    $vol += $n[$_] * $TVOL[$_]; 
	    
	    $sum += $n[$_];
	    
	    last if ($lote - $sum <= 0);
	}
	
	if ($vol > $maxvol[$lote]){
	    $maxvol[$lote] = $vol;
	    my @nmax = @n;
	    # system "clear";
	    for (my $l = 10; $l <= 50; $l += 5){
		say "size $l fleet -> vol $maxvol[$l]   listed:";
		say "type $_    num_vessels $nmax[$_]" for (0 .. scalar(@TVOL)-1);
		say "";
	    }
	}	
    }
}

exit 3;

