from itertools import combinations
def maximize_exhibition_value(N, artworks):
max_value = float('-inf')
# Try every possible non-empty subset
for r in range(1, N+1):
for subset in combinations(artworks, r):
sizes = [art[0] for art in subset]
values = [art[1] for art in subset]
A_max = max(sizes)
A_min = min(sizes)
S = sum(values)
current_value = S - (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 |
1 |
Correct |
88 ms |
2908 KB |
Output is correct |
2 |
Correct |
86 ms |
2908 KB |
Output is correct |
3 |
Correct |
89 ms |
2908 KB |
Output is correct |
4 |
Correct |
90 ms |
2992 KB |
Output is correct |
5 |
Correct |
91 ms |
2908 KB |
Output is correct |
6 |
Correct |
92 ms |
2996 KB |
Output is correct |
7 |
Correct |
88 ms |
2908 KB |
Output is correct |
8 |
Correct |
90 ms |
3000 KB |
Output is correct |
9 |
Correct |
90 ms |
2908 KB |
Output is correct |
10 |
Correct |
92 ms |
2908 KB |
Output is correct |
11 |
Correct |
90 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
2908 KB |
Output is correct |
2 |
Correct |
86 ms |
2908 KB |
Output is correct |
3 |
Correct |
89 ms |
2908 KB |
Output is correct |
4 |
Correct |
90 ms |
2992 KB |
Output is correct |
5 |
Correct |
91 ms |
2908 KB |
Output is correct |
6 |
Correct |
92 ms |
2996 KB |
Output is correct |
7 |
Correct |
88 ms |
2908 KB |
Output is correct |
8 |
Correct |
90 ms |
3000 KB |
Output is correct |
9 |
Correct |
90 ms |
2908 KB |
Output is correct |
10 |
Correct |
92 ms |
2908 KB |
Output is correct |
11 |
Correct |
90 ms |
2908 KB |
Output is correct |
12 |
Execution timed out |
1032 ms |
2908 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
2908 KB |
Output is correct |
2 |
Correct |
86 ms |
2908 KB |
Output is correct |
3 |
Correct |
89 ms |
2908 KB |
Output is correct |
4 |
Correct |
90 ms |
2992 KB |
Output is correct |
5 |
Correct |
91 ms |
2908 KB |
Output is correct |
6 |
Correct |
92 ms |
2996 KB |
Output is correct |
7 |
Correct |
88 ms |
2908 KB |
Output is correct |
8 |
Correct |
90 ms |
3000 KB |
Output is correct |
9 |
Correct |
90 ms |
2908 KB |
Output is correct |
10 |
Correct |
92 ms |
2908 KB |
Output is correct |
11 |
Correct |
90 ms |
2908 KB |
Output is correct |
12 |
Execution timed out |
1032 ms |
2908 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
2908 KB |
Output is correct |
2 |
Correct |
86 ms |
2908 KB |
Output is correct |
3 |
Correct |
89 ms |
2908 KB |
Output is correct |
4 |
Correct |
90 ms |
2992 KB |
Output is correct |
5 |
Correct |
91 ms |
2908 KB |
Output is correct |
6 |
Correct |
92 ms |
2996 KB |
Output is correct |
7 |
Correct |
88 ms |
2908 KB |
Output is correct |
8 |
Correct |
90 ms |
3000 KB |
Output is correct |
9 |
Correct |
90 ms |
2908 KB |
Output is correct |
10 |
Correct |
92 ms |
2908 KB |
Output is correct |
11 |
Correct |
90 ms |
2908 KB |
Output is correct |
12 |
Execution timed out |
1032 ms |
2908 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |