Submission #1108359

#TimeUsernameProblemLanguageResultExecution timeMemory
1108359vjudge1Art Exhibition (JOI18_art)Pypy 2
0 / 100
47 ms27460 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...