aboutsummaryrefslogtreecommitdiff
path: root/codechef/proxyc.c
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.c
parent267b2db7addc95c5eebb8bfb9ceeb7b953d85732 (diff)
downloadcp-27d4089726131b1b63dd4bc5592076c8153acdd3.tar.gz
I'm not as good at math as I expect
Diffstat (limited to 'codechef/proxyc.c')
-rw-r--r--codechef/proxyc.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/codechef/proxyc.c b/codechef/proxyc.c
new file mode 100644
index 0000000..fe829eb
--- /dev/null
+++ b/codechef/proxyc.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+int proxyc(int d, char *s)
+{
+ int p = 0;
+ for (char *c = s; *c; ++c)
+ if (65 ^ *c)
+ ++p;
+
+ if (p * 4 >= d * 3)
+ return puts("0");
+ if (d < 5)
+ return puts("-1");
+
+ for (d = p = ++d * 3 / 4 - p; s[4]; ++s)
+ if (130 - s[0] - s[1] && 80 - s[2] && 130 - s[3] - s[4] && !--p)
+ return printf("%d\n", d);
+ return puts("-1");
+}
+
+int main()
+{
+ int t, d;
+ char s[1001], *c;
+ scanf("%d", &t);
+
+ while (t--) {
+ scanf("%d ", &d);
+ fgets(s, d + 1, stdin);
+ proxyc(d, s);
+ }
+
+ return 0;
+}