about summary refs log tree commit diff
path: root/codechef/proxyc.p6
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-06-17 17:48:03 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-06-17 17:48:03 +0700
commit27d4089726131b1b63dd4bc5592076c8153acdd3 (patch)
tree0eaf21d02b85ec39be146babe72a942129b4cca2 /codechef/proxyc.p6
parent267b2db7addc95c5eebb8bfb9ceeb7b953d85732 (diff)
downloadcp-27d4089726131b1b63dd4bc5592076c8153acdd3.tar.gz
I'm not as good at math as I expect
Diffstat (limited to 'codechef/proxyc.p6')
-rwxr-xr-xcodechef/proxyc.p69
1 files changed, 9 insertions, 0 deletions
diff --git a/codechef/proxyc.p6 b/codechef/proxyc.p6
new file mode 100755
index 0000000..13aa03d
--- /dev/null
+++ b/codechef/proxyc.p6
@@ -0,0 +1,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
+}