A big bomb death of 9 pena. Thanks to the last-minute E problem one and a half minutes before the end, the rating was slightly down.
Break through in 1 minute. Just write.
X = int(input())
if X >= 30:
print('Yes')
else:
print('No')
Break through in two and a half minutes. Just write.
N, D = map(int, input().split())
result = 0
for _ in range(N):
X, Y = map(int, input().split())
if X * X + Y * Y <= D * D:
result += 1
print(result)
Break through in about 20 minutes. RE × 1, WA × 4. Repeat swapping the leftmost white stone with the rightmost red stone until there is no red stone on the right side of the white stone. Good. It's easy to say, but I'm addicted to the implementation ...
N = int(input())
c = input()
d = list(c)
i = 0
j = N - 1
result = 0
while True:
while i < N and d[i] != 'W':
i += 1
while j > 0 and d[j] != 'R':
j -= 1
if i == N or j == -1 or i >= j:
break
d[i] = 'R'
d[j] = 'W'
result += 1
print(result)
It broke through in about 28 minutes. I thought that I could write it naive because it was a C problem, but I ate TLE in input example 3 and it was deep blue. Probably the maximum value was K-1
K = int(input())
t = 7
for i in range(K):
if t % K == 0:
print(i + 1)
break
t = (t * 10 + 7) % K
else:
print(-1)
Addendum: The maximum value was decided to be K-1 because there are K-1 types except 0, which is the remainder divided by K. If the same value appears in the middle, it will not be 0 because it is a loop.
Break through in 47 minutes. TLE × 1, RE × 3. Write and submit the code that gives the correct answer with heapq, and then notice K ≤ 10 9 </ sup>. Efforts to speed up with heapq for 24 minutes After doing this, I flashed at the moment when it failed, and I wrote the code in 13 minutes and it was already one and a half minutes before the end. I passed, it was saved. But ʻabs (ng --ok)> I used to go by 1`.
from math import ceil
N, K, *A = map(int, open(0).read().split())
def is_ok(n):
t = 0
for a in A:
if a <= n:
continue
t += ceil(a / n) - 1
return t <= K
ok = 1000000000
ng = 0.0000000001
while abs(ng - ok) > 1:
m = (ok + ng) // 2
if is_ok(m):
ok = m
else:
ng = m
print(ceil(ok))
Recommended Posts