#!/usr/bin/perl
use warnings;
use strict;
use List::Util qw[min max];
my $chocolate=0.79;
my $licorice= 0.59;
my $gummi= 0.95;
my $money=4;
my $maxcho=int($money/$chocolate);
my $maxlic=int($money/$licorice);
my $maxgummi=int($money/$gummi);
my @cost;
my $maxcandy=max($maxcho,$maxlic,$maxgummi);
for my $i(0..$maxcandy){
	for my $j(0..$maxcandy){
		for my $k(0..$maxcandy){
		#push to the cost only if cost less than total money
		push @cost,($i*$chocolate)+($j*$licorice)+($k*$gummi) if ($i*$chocolate)+($j*$licorice)+($k*$gummi)<=$money;
		}
	}
}
print max(@cost),"\n";
