n=int(input())
mas=[]
for i in range(n):
mas.append(list(map(int,input().split())))
mas.sort(key=lambda x:x[0])
maxi=0
for i in range(n):
mx=0
mn=10**15+7
sm=0
for j in range(i,n):
mx=max(mas[j][0],mx)
mn=min(mas[j][0],mn)
sm+=mas[j][1]
maxi=max(maxi,sm-mx+mn)
print(maxi)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2908 KB |
Output is correct |
3 |
Correct |
8 ms |
2908 KB |
Output is correct |
4 |
Correct |
9 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2900 KB |
Output is correct |
6 |
Correct |
8 ms |
2980 KB |
Output is correct |
7 |
Correct |
9 ms |
2908 KB |
Output is correct |
8 |
Correct |
13 ms |
2908 KB |
Output is correct |
9 |
Correct |
9 ms |
2756 KB |
Output is correct |
10 |
Correct |
8 ms |
2908 KB |
Output is correct |
11 |
Correct |
9 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2908 KB |
Output is correct |
3 |
Correct |
8 ms |
2908 KB |
Output is correct |
4 |
Correct |
9 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2900 KB |
Output is correct |
6 |
Correct |
8 ms |
2980 KB |
Output is correct |
7 |
Correct |
9 ms |
2908 KB |
Output is correct |
8 |
Correct |
13 ms |
2908 KB |
Output is correct |
9 |
Correct |
9 ms |
2756 KB |
Output is correct |
10 |
Correct |
8 ms |
2908 KB |
Output is correct |
11 |
Correct |
9 ms |
2908 KB |
Output is correct |
12 |
Correct |
35 ms |
2908 KB |
Output is correct |
13 |
Correct |
33 ms |
2908 KB |
Output is correct |
14 |
Correct |
34 ms |
2908 KB |
Output is correct |
15 |
Correct |
34 ms |
2908 KB |
Output is correct |
16 |
Correct |
34 ms |
2908 KB |
Output is correct |
17 |
Correct |
35 ms |
2908 KB |
Output is correct |
18 |
Correct |
35 ms |
3040 KB |
Output is correct |
19 |
Correct |
43 ms |
2908 KB |
Output is correct |
20 |
Correct |
34 ms |
2908 KB |
Output is correct |
21 |
Correct |
35 ms |
2908 KB |
Output is correct |
22 |
Correct |
43 ms |
2908 KB |
Output is correct |
23 |
Correct |
36 ms |
2908 KB |
Output is correct |
24 |
Correct |
37 ms |
2908 KB |
Output is correct |
25 |
Correct |
34 ms |
2908 KB |
Output is correct |
26 |
Correct |
38 ms |
3160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2908 KB |
Output is correct |
3 |
Correct |
8 ms |
2908 KB |
Output is correct |
4 |
Correct |
9 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2900 KB |
Output is correct |
6 |
Correct |
8 ms |
2980 KB |
Output is correct |
7 |
Correct |
9 ms |
2908 KB |
Output is correct |
8 |
Correct |
13 ms |
2908 KB |
Output is correct |
9 |
Correct |
9 ms |
2756 KB |
Output is correct |
10 |
Correct |
8 ms |
2908 KB |
Output is correct |
11 |
Correct |
9 ms |
2908 KB |
Output is correct |
12 |
Correct |
35 ms |
2908 KB |
Output is correct |
13 |
Correct |
33 ms |
2908 KB |
Output is correct |
14 |
Correct |
34 ms |
2908 KB |
Output is correct |
15 |
Correct |
34 ms |
2908 KB |
Output is correct |
16 |
Correct |
34 ms |
2908 KB |
Output is correct |
17 |
Correct |
35 ms |
2908 KB |
Output is correct |
18 |
Correct |
35 ms |
3040 KB |
Output is correct |
19 |
Correct |
43 ms |
2908 KB |
Output is correct |
20 |
Correct |
34 ms |
2908 KB |
Output is correct |
21 |
Correct |
35 ms |
2908 KB |
Output is correct |
22 |
Correct |
43 ms |
2908 KB |
Output is correct |
23 |
Correct |
36 ms |
2908 KB |
Output is correct |
24 |
Correct |
37 ms |
2908 KB |
Output is correct |
25 |
Correct |
34 ms |
2908 KB |
Output is correct |
26 |
Correct |
38 ms |
3160 KB |
Output is correct |
27 |
Execution timed out |
1077 ms |
3932 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2908 KB |
Output is correct |
3 |
Correct |
8 ms |
2908 KB |
Output is correct |
4 |
Correct |
9 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2900 KB |
Output is correct |
6 |
Correct |
8 ms |
2980 KB |
Output is correct |
7 |
Correct |
9 ms |
2908 KB |
Output is correct |
8 |
Correct |
13 ms |
2908 KB |
Output is correct |
9 |
Correct |
9 ms |
2756 KB |
Output is correct |
10 |
Correct |
8 ms |
2908 KB |
Output is correct |
11 |
Correct |
9 ms |
2908 KB |
Output is correct |
12 |
Correct |
35 ms |
2908 KB |
Output is correct |
13 |
Correct |
33 ms |
2908 KB |
Output is correct |
14 |
Correct |
34 ms |
2908 KB |
Output is correct |
15 |
Correct |
34 ms |
2908 KB |
Output is correct |
16 |
Correct |
34 ms |
2908 KB |
Output is correct |
17 |
Correct |
35 ms |
2908 KB |
Output is correct |
18 |
Correct |
35 ms |
3040 KB |
Output is correct |
19 |
Correct |
43 ms |
2908 KB |
Output is correct |
20 |
Correct |
34 ms |
2908 KB |
Output is correct |
21 |
Correct |
35 ms |
2908 KB |
Output is correct |
22 |
Correct |
43 ms |
2908 KB |
Output is correct |
23 |
Correct |
36 ms |
2908 KB |
Output is correct |
24 |
Correct |
37 ms |
2908 KB |
Output is correct |
25 |
Correct |
34 ms |
2908 KB |
Output is correct |
26 |
Correct |
38 ms |
3160 KB |
Output is correct |
27 |
Execution timed out |
1077 ms |
3932 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |