diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-12-16 21:13:07 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-12-16 21:13:07 +0700 |
commit | c1008fe39217be7f91f0ea23483e747bfbc5743e (patch) | |
tree | c4f921bccd9e8d66e3aadd9a01ede3300d73afa6 /codechef/subsplay.c | |
parent | 8a9d6282fcb863c67d6623f5c883ef703721cccd (diff) | |
download | cp-c1008fe39217be7f91f0ea23483e747bfbc5743e.tar.gz |
The good, the bad and the ugly
Diffstat (limited to 'codechef/subsplay.c')
-rw-r--r-- | codechef/subsplay.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/codechef/subsplay.c b/codechef/subsplay.c new file mode 100644 index 0000000..691a04e --- /dev/null +++ b/codechef/subsplay.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +int main() +{ + int t, n; + + scanf("%d", &t); + while (t--) { + int k = 0, hope[26] = {0}; + scanf("%d ", &n); + for (int i = 0; i < n; ++i) { + int c = getchar() - 'a'; + if (hope[c] - i > k) + k = hope[c] - i; + hope[c] = n + i; + } + printf("%d\n", k); + } + + return 0; +} |