from sys import stdin
range = xrange
raw_input = stdin.readline
N = int(raw_input())
L = [None]*N
for i in range(N):
a, b = map(int, raw_input().split())
L[i] = (a, b)
L.sort()
S = [0]*(N+1)
for i in range(N):
a, b = L[i]
S[i+1] = S[i] + b
ans = 0
for j in range(N):
for i in range(j+1):
ans = max(ans, S[j+1] - S[i] + L[i][0] - L[j][0])
print ans
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
10944 KB |
Output is correct |
2 |
Correct |
31 ms |
11140 KB |
Output is correct |
3 |
Correct |
28 ms |
11140 KB |
Output is correct |
4 |
Correct |
29 ms |
11140 KB |
Output is correct |
5 |
Correct |
29 ms |
11140 KB |
Output is correct |
6 |
Correct |
29 ms |
11140 KB |
Output is correct |
7 |
Correct |
30 ms |
11140 KB |
Output is correct |
8 |
Correct |
28 ms |
11140 KB |
Output is correct |
9 |
Correct |
28 ms |
11168 KB |
Output is correct |
10 |
Correct |
29 ms |
11208 KB |
Output is correct |
11 |
Correct |
30 ms |
11212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
10944 KB |
Output is correct |
2 |
Correct |
31 ms |
11140 KB |
Output is correct |
3 |
Correct |
28 ms |
11140 KB |
Output is correct |
4 |
Correct |
29 ms |
11140 KB |
Output is correct |
5 |
Correct |
29 ms |
11140 KB |
Output is correct |
6 |
Correct |
29 ms |
11140 KB |
Output is correct |
7 |
Correct |
30 ms |
11140 KB |
Output is correct |
8 |
Correct |
28 ms |
11140 KB |
Output is correct |
9 |
Correct |
28 ms |
11168 KB |
Output is correct |
10 |
Correct |
29 ms |
11208 KB |
Output is correct |
11 |
Correct |
30 ms |
11212 KB |
Output is correct |
12 |
Correct |
40 ms |
13668 KB |
Output is correct |
13 |
Correct |
40 ms |
13824 KB |
Output is correct |
14 |
Correct |
41 ms |
13848 KB |
Output is correct |
15 |
Correct |
39 ms |
13872 KB |
Output is correct |
16 |
Correct |
39 ms |
13872 KB |
Output is correct |
17 |
Correct |
45 ms |
13924 KB |
Output is correct |
18 |
Correct |
37 ms |
13924 KB |
Output is correct |
19 |
Correct |
38 ms |
13924 KB |
Output is correct |
20 |
Correct |
40 ms |
14056 KB |
Output is correct |
21 |
Correct |
47 ms |
14056 KB |
Output is correct |
22 |
Correct |
41 ms |
14056 KB |
Output is correct |
23 |
Correct |
39 ms |
14056 KB |
Output is correct |
24 |
Correct |
37 ms |
14056 KB |
Output is correct |
25 |
Correct |
41 ms |
14056 KB |
Output is correct |
26 |
Correct |
38 ms |
14056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
10944 KB |
Output is correct |
2 |
Correct |
31 ms |
11140 KB |
Output is correct |
3 |
Correct |
28 ms |
11140 KB |
Output is correct |
4 |
Correct |
29 ms |
11140 KB |
Output is correct |
5 |
Correct |
29 ms |
11140 KB |
Output is correct |
6 |
Correct |
29 ms |
11140 KB |
Output is correct |
7 |
Correct |
30 ms |
11140 KB |
Output is correct |
8 |
Correct |
28 ms |
11140 KB |
Output is correct |
9 |
Correct |
28 ms |
11168 KB |
Output is correct |
10 |
Correct |
29 ms |
11208 KB |
Output is correct |
11 |
Correct |
30 ms |
11212 KB |
Output is correct |
12 |
Correct |
40 ms |
13668 KB |
Output is correct |
13 |
Correct |
40 ms |
13824 KB |
Output is correct |
14 |
Correct |
41 ms |
13848 KB |
Output is correct |
15 |
Correct |
39 ms |
13872 KB |
Output is correct |
16 |
Correct |
39 ms |
13872 KB |
Output is correct |
17 |
Correct |
45 ms |
13924 KB |
Output is correct |
18 |
Correct |
37 ms |
13924 KB |
Output is correct |
19 |
Correct |
38 ms |
13924 KB |
Output is correct |
20 |
Correct |
40 ms |
14056 KB |
Output is correct |
21 |
Correct |
47 ms |
14056 KB |
Output is correct |
22 |
Correct |
41 ms |
14056 KB |
Output is correct |
23 |
Correct |
39 ms |
14056 KB |
Output is correct |
24 |
Correct |
37 ms |
14056 KB |
Output is correct |
25 |
Correct |
41 ms |
14056 KB |
Output is correct |
26 |
Correct |
38 ms |
14056 KB |
Output is correct |
27 |
Correct |
147 ms |
18028 KB |
Output is correct |
28 |
Correct |
152 ms |
18176 KB |
Output is correct |
29 |
Correct |
143 ms |
18304 KB |
Output is correct |
30 |
Correct |
155 ms |
18432 KB |
Output is correct |
31 |
Correct |
148 ms |
18568 KB |
Output is correct |
32 |
Correct |
147 ms |
18584 KB |
Output is correct |
33 |
Correct |
154 ms |
18728 KB |
Output is correct |
34 |
Correct |
148 ms |
18944 KB |
Output is correct |
35 |
Correct |
217 ms |
19016 KB |
Output is correct |
36 |
Correct |
188 ms |
19152 KB |
Output is correct |
37 |
Correct |
166 ms |
19284 KB |
Output is correct |
38 |
Correct |
144 ms |
19464 KB |
Output is correct |
39 |
Correct |
146 ms |
19588 KB |
Output is correct |
40 |
Correct |
174 ms |
19720 KB |
Output is correct |
41 |
Correct |
152 ms |
19848 KB |
Output is correct |
42 |
Correct |
156 ms |
19940 KB |
Output is correct |
43 |
Correct |
157 ms |
20092 KB |
Output is correct |
44 |
Correct |
161 ms |
20220 KB |
Output is correct |
45 |
Correct |
153 ms |
20348 KB |
Output is correct |
46 |
Correct |
146 ms |
20464 KB |
Output is correct |
47 |
Correct |
147 ms |
20604 KB |
Output is correct |
48 |
Correct |
152 ms |
20644 KB |
Output is correct |
49 |
Correct |
176 ms |
20864 KB |
Output is correct |
50 |
Correct |
158 ms |
20992 KB |
Output is correct |
51 |
Correct |
206 ms |
21116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
10944 KB |
Output is correct |
2 |
Correct |
31 ms |
11140 KB |
Output is correct |
3 |
Correct |
28 ms |
11140 KB |
Output is correct |
4 |
Correct |
29 ms |
11140 KB |
Output is correct |
5 |
Correct |
29 ms |
11140 KB |
Output is correct |
6 |
Correct |
29 ms |
11140 KB |
Output is correct |
7 |
Correct |
30 ms |
11140 KB |
Output is correct |
8 |
Correct |
28 ms |
11140 KB |
Output is correct |
9 |
Correct |
28 ms |
11168 KB |
Output is correct |
10 |
Correct |
29 ms |
11208 KB |
Output is correct |
11 |
Correct |
30 ms |
11212 KB |
Output is correct |
12 |
Correct |
40 ms |
13668 KB |
Output is correct |
13 |
Correct |
40 ms |
13824 KB |
Output is correct |
14 |
Correct |
41 ms |
13848 KB |
Output is correct |
15 |
Correct |
39 ms |
13872 KB |
Output is correct |
16 |
Correct |
39 ms |
13872 KB |
Output is correct |
17 |
Correct |
45 ms |
13924 KB |
Output is correct |
18 |
Correct |
37 ms |
13924 KB |
Output is correct |
19 |
Correct |
38 ms |
13924 KB |
Output is correct |
20 |
Correct |
40 ms |
14056 KB |
Output is correct |
21 |
Correct |
47 ms |
14056 KB |
Output is correct |
22 |
Correct |
41 ms |
14056 KB |
Output is correct |
23 |
Correct |
39 ms |
14056 KB |
Output is correct |
24 |
Correct |
37 ms |
14056 KB |
Output is correct |
25 |
Correct |
41 ms |
14056 KB |
Output is correct |
26 |
Correct |
38 ms |
14056 KB |
Output is correct |
27 |
Correct |
147 ms |
18028 KB |
Output is correct |
28 |
Correct |
152 ms |
18176 KB |
Output is correct |
29 |
Correct |
143 ms |
18304 KB |
Output is correct |
30 |
Correct |
155 ms |
18432 KB |
Output is correct |
31 |
Correct |
148 ms |
18568 KB |
Output is correct |
32 |
Correct |
147 ms |
18584 KB |
Output is correct |
33 |
Correct |
154 ms |
18728 KB |
Output is correct |
34 |
Correct |
148 ms |
18944 KB |
Output is correct |
35 |
Correct |
217 ms |
19016 KB |
Output is correct |
36 |
Correct |
188 ms |
19152 KB |
Output is correct |
37 |
Correct |
166 ms |
19284 KB |
Output is correct |
38 |
Correct |
144 ms |
19464 KB |
Output is correct |
39 |
Correct |
146 ms |
19588 KB |
Output is correct |
40 |
Correct |
174 ms |
19720 KB |
Output is correct |
41 |
Correct |
152 ms |
19848 KB |
Output is correct |
42 |
Correct |
156 ms |
19940 KB |
Output is correct |
43 |
Correct |
157 ms |
20092 KB |
Output is correct |
44 |
Correct |
161 ms |
20220 KB |
Output is correct |
45 |
Correct |
153 ms |
20348 KB |
Output is correct |
46 |
Correct |
146 ms |
20464 KB |
Output is correct |
47 |
Correct |
147 ms |
20604 KB |
Output is correct |
48 |
Correct |
152 ms |
20644 KB |
Output is correct |
49 |
Correct |
176 ms |
20864 KB |
Output is correct |
50 |
Correct |
158 ms |
20992 KB |
Output is correct |
51 |
Correct |
206 ms |
21116 KB |
Output is correct |
52 |
Execution timed out |
1071 ms |
51264 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |