complete 25425.py 29766.py 29767.py 29768.py
This commit is contained in:
24
zeta_python/completed/25425.py
Normal file
24
zeta_python/completed/25425.py
Normal file
@@ -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())
|
||||||
10
zeta_python/completed/29766.py
Normal file
10
zeta_python/completed/29766.py
Normal file
@@ -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)
|
||||||
20
zeta_python/completed/29767.py
Normal file
20
zeta_python/completed/29767.py
Normal file
@@ -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())
|
||||||
17
zeta_python/completed/29768.py
Normal file
17
zeta_python/completed/29768.py
Normal file
@@ -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())
|
||||||
Reference in New Issue
Block a user