답안 #1050346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050346 2024-08-09T08:51:18 Z vjudge1 Art Exhibition (JOI18_art) Python 3
0 / 100
11 ms 2948 KB
def maximize_exhibition_value(N, artworks):
    artworks.sort()

    max_value = float('-inf')
    current_sum = 0
    left = 0

    for right in range(N):
        current_sum += artworks[right][1]

        A_max = artworks[right][0]
        A_min = artworks[left][0]
        current_value = current_sum - (A_max - A_min)

        max_value = max(max_value, current_value)

        while left < right and (current_sum - artworks[left][1]) - (artworks[right][0] - artworks[left + 1][0]) >= current_value:
            current_sum -= artworks[left][1]
            left += 1
            A_min = artworks[left][0]
            current_value = current_sum - (A_max - A_min)
            max_value = max(max_value, current_value)

    return max_value

N = int(input().strip())
artworks = []
for _ in range(N):
    A, B = map(int, input().strip().split())
    artworks.append((A, B))

result = maximize_exhibition_value(N, artworks)
print(result)
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2948 KB Output is correct
2 Correct 11 ms 2784 KB Output is correct
3 Incorrect 9 ms 2908 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2948 KB Output is correct
2 Correct 11 ms 2784 KB Output is correct
3 Incorrect 9 ms 2908 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2948 KB Output is correct
2 Correct 11 ms 2784 KB Output is correct
3 Incorrect 9 ms 2908 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2948 KB Output is correct
2 Correct 11 ms 2784 KB Output is correct
3 Incorrect 9 ms 2908 KB Output isn't correct
4 Halted 0 ms 0 KB -