이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import sys
sys.stdin = open('input.txt', 'r')
input = sys.stdin.readline
class Balloon:
__slots__ = ['x', 'max_radius', 'curr_radius']
def __init__(self, x: int, max_radius: int, curr_radius: float = float('inf')) -> None:
self.x = x
self.max_radius = max_radius
self.curr_radius = curr_radius
def find_max_radius(b1: Balloon, b2: Balloon):
# b1 is the already inflated balloon, b2 is the one we want to find
return ((b1.x - b2.x) ** 2) / (4 * b1.curr_radius)
stack: list[Balloon] = []
radii: list[int] = []
n = int(input())
for _ in range(n):
x, r = map(int, input().split())
new_balloon = Balloon(x, r)
# find max_radius
# if max_radius > b3.max_radius:
# if b3.max_radius > b2.curr_radius:
# pop, continue with loop
# else:
# set balloon radius to min(b3.curr, b3.max, max_radius)
# else
# set b.curr_radius to radius, continue with loop
# find max_radius
# if max_radius > b2.curr_radius:
# pop, set radius to min, continue with loop
# if max_radius > b3.max_radius: -> means it
# set radius to min(max_radius, curr), continue with
while stack:
new_balloon_radius = find_max_radius(stack[-1], new_balloon)
# print(new_balloon_radius)
new_balloon.curr_radius = min(new_balloon.curr_radius,
new_balloon.max_radius, new_balloon_radius)
if new_balloon.curr_radius >= stack[-1].curr_radius:
stack.pop()
continue
else:
break
new_balloon.curr_radius = min(new_balloon.curr_radius, new_balloon.max_radius)
stack.append(new_balloon)
radii.append(new_balloon.curr_radius)
print(*radii, sep='\n')
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |