It broke through in two and a half minutes. I was confused for a moment that there were five variables, but I just wrote it.
S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:
A -= 1
else:
B -= 1
print(A, B)
Break through in 1 minute. Just write.
S = input()
print('x' * len(S))
Break through in 2 minutes. Just write. I remembered ABC063B --Varied.
N = int(input())
A = list(map(int, input().split()))
if len(set(A)) == N:
print('YES')
else:
print('NO')
Break through in 10 minutes. From list p, just make a list m of mean values and find the maximum value in a Sliding Window with width K.
N, K = map(int, input().split())
p = list(map(int, input().split()))
m = [(e + 1) / 2 for e in p]
t = sum(m[0:K])
result = t
for i in range(N - K):
t -= m[i]
t += m[i + K]
if t > result:
result = t
print(result)
ABC154E - Almost Everywhere Zero
Lost. I thought it was the same problem that I had left unsolved before, but I was out of luck because I didn't solve it at that time ...
Addendum: It's fine to do digit DP, but since Python slows down as the order of the list goes up, I wrote the variables separately without raising the dimension.
N = input()
K = int(input())
a = 1
b = [0] * (K + 1)
b[0] = 1
b[1] = int(N[0]) - 1
for c in N[1:]:
t = int(c)
for i in range(K - 1, -1, -1):
b[i + 1] += b[i] * 9
if t != 0:
if a + 1 <= K:
b[a + 1] += t - 1
if a <= K:
b[a] += 1
a += 1
if a == K:
print(b[K] + 1)
else:
print(b[K])
Recommended Posts