diff --git a/zeta_python/completed/25425.py b/zeta_python/completed/25425.py new file mode 100644 index 0000000..f5a9127 --- /dev/null +++ b/zeta_python/completed/25425.py @@ -0,0 +1,24 @@ +class RankRange: + def __init__(self, N, M, a, K): + # N: team, M: max person per team, a: remains, K: my team + self.N, self.M, self.a, self.K = N, M, a, K + + def solve(self): + worst, best = -1, -1 + + except_us = self.a - self.K + # worst case 1 + if except_us >= self.N - 1: + worst = self.N + else: + worst = except_us + 1 + + # best case + d, m = divmod(except_us, self.M) + best = d + 1 if m == 0 else d + 2 + return worst, best + + +if __name__ == "__main__": + N, M, a, K = map(int, input().split()) + print(*RankRange(N, M, a, K).solve()) diff --git a/zeta_python/completed/29766.py b/zeta_python/completed/29766.py new file mode 100644 index 0000000..202677f --- /dev/null +++ b/zeta_python/completed/29766.py @@ -0,0 +1,10 @@ +if __name__ == "__main__": + S = input() + cnt = 0 + now = 0 + find = S.find("DKSH", now) + while find != -1: + cnt += 1 + now = find + 4 + find = S.find("DKSH", now) + print(cnt) diff --git a/zeta_python/completed/29767.py b/zeta_python/completed/29767.py new file mode 100644 index 0000000..2b518b0 --- /dev/null +++ b/zeta_python/completed/29767.py @@ -0,0 +1,20 @@ +class ToMaximize: + def __init__(self, N: int, K: int, A: list[int]): + self.N, self.K, self.A = N, K, A + + def solve(self): + cumA = [] + ss = 0 + for i in range(self.N): + ss += self.A[i] + cumA.append((ss, i)) + cumA.sort(key=lambda x: x[0]) + + popped = [cumA.pop()[0] for _ in range(self.K)] + return sum(popped) + + +if __name__ == "__main__": + N, K = map(int, input().split()) + A = list(map(int, input().split())) + print(ToMaximize(N, K, A).solve()) diff --git a/zeta_python/completed/29768.py b/zeta_python/completed/29768.py new file mode 100644 index 0000000..05a9f74 --- /dev/null +++ b/zeta_python/completed/29768.py @@ -0,0 +1,17 @@ +class PalindromeGenerator: + def __init__(self, N, K): + self.N, self.K = N, K + + def solve(self) -> str: + S = "abcdefghijklmnopqrstuvwxyz" + return "a" * (self.N - (self.K - 1)) + S[1 : self.K] + + +if __name__ == "__main__": + # 3 1 => aaa + # N 1 =. a...a. + # 3 2 => aba + # 4 2 => aaab + # aaaaaaaaaaaaaaabc + N, K = map(int, input().split()) + print(PalindromeGenerator(N, K).solve())