This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
def maximize_exhibition_value(N, artworks):
# Sort artworks by their size A
artworks.sort()
max_value = float('-inf')
for i in range(N):
current_sum = 0
A_min = artworks[i][0]
for j in range(i, N):
current_sum += artworks[j][1]
A_max = artworks[j][0]
current_value = current_sum - (A_max - A_min)
max_value = max(max_value, current_value)
return max_value
# Input reading
N = int(input().strip())
artworks = []
for _ in range(N):
A, B = map(int, input().strip().split())
artworks.append((A, B))
# Calculate and print the result
result = maximize_exhibition_value(N, artworks)
print(result)
# | 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... |