about summary refs log tree commit diff
path: root/codechef/proxyc.p6
blob: 13aa03d584ab1689acaf0e00ea919cfdedebeaab (plain) (blame)
1
2
3
4
5
6
7
8
9
#!/usr/bin/env perl6
my @a = <AP PP PA>;
for ^get() {
    my ($d, $s) = get.Int, get;
    my $p = elems $s ~~ m:g/P/;
    put 0 when $p * 4 >= $d * 3;
    my $m = ceiling $d * 0.75 - $p;
    put ($m > elems $s ~~ m:g:ex/@a A @a/) ?? -1 !! $m
}