Break through in two and a half minutes. Just write. It took a long time because the code test was clogged.
S = input()
if S == 'ABC':
print('ARC')
elif S == 'ARC':
print('ABC')
Break through in two and a half minutes. Is it difficult for B problem? Manage whether you have it or not at the table, write to the table that the person who has it has it, and the person who does not have it at the end Just add up.
N, K = map(int, input().split())
t = [0] * N
for _ in range(K):
d = int(input())
A = list(map(int, input().split()))
for a in A:
t[a - 1] += 1
print(t.count(0))
Break through in 6 and a half minutes. Just update the highest peak of the observatory adjacent to the table and finally compare the height with the highest peak of the adjacent observatory.
N, M = map(int, input().split())
H = list(map(int, input().split()))
t = [0] * N
for _ in range(M):
A, B = map(int, input().split())
t[A - 1] = max(t[A - 1], H[B - 1])
t[B - 1] = max(t[B - 1], H[A - 1])
result = 0
for i in range(N):
if H[i] > t[i]:
result += 1
print(result)
ABC166D - I hate Factorization
Break through in 6 and a half minutes. If A is negative, B will be negative and both patterns will be positive, so A should be 0 or more. After that, if there is 10 3 </ sup>, 10 It can cover up to 15 </ sup>, and * O * (2 × 10 6 </ sup>), so it's probably like TLE. AC. First 100 and WA1 orz.
X = int(input())
for A in range(1000):
for B in range(-1000, 1000):
if A ** 5 - B ** 5 == X:
print(A, B)
exit()
ABC166E - This Message Will Self-Destruct in 5s
Defeat
Addendum: Implementation according to the explanation PDF. Expression transformation?
N = int(input())
A = list(map(int, input().split()))
c1 = {}
c2 = {}
for i in range(N):
c1.setdefault(i + A[i], 0)
c1[i + A[i]] += 1
c2.setdefault(i - A[i], 0)
c2[i - A[i]] += 1
result = 0
for k in set(c1).intersection(c2):
result += c1[k] * c2[k]
print(result)
Recommended Posts