From 27d4089726131b1b63dd4bc5592076c8153acdd3 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 17 Jun 2019 17:48:03 +0700 Subject: I'm not as good at math as I expect --- codechef/proxyc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 codechef/proxyc.c (limited to 'codechef/proxyc.c') 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 + +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; +} -- cgit 1.4.1