Submission #1108359

# Submission time Handle Problem Language Result Execution time Memory
1108359 2024-11-04T01:16:51 Z vjudge1 Art Exhibition (JOI18_art) PyPy
0 / 100
47 ms 27460 KB
import sys

# Define the maximum size of the item list
N = 10**6 + 5

# Read input from a file if provided
input_file = "Flower.inp"
output_file = "Flower.out"

if len(sys.argv) > 1 and sys.argv[1] == 'file':
    sys.stdin = open(input_file, 'r')
    sys.stdout = open(output_file, 'w')

# Read number of items
n = int(input())
item = [None] * (N)

# Read item pairs
for i in range(1, n + 1):
    x, y = map(int, input().split())
    item[i] = (x, y)

# Sort items based on the first element of the tuple
item[1:n + 1] = sorted(item[1:n + 1], key=lambda x: x[0])

# Prefix sums
p = [0] * (N)
for i in range(1, n + 1):
    p[i] = p[i - 1] + item[i][1]

# Calculate the result
res = 0
for i in range(1, n + 1):
    res = max(res, p[i] + item[1][0] - item[i][0])

# Output the result
print(res)
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 27460 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 27460 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 27460 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 27460 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -