#include <bits/stdc++.h>
using namespace std;
long long n ;
vector< pair<long long , long long> >vp ;
int main()
{
cin>>n ;
for(long long i = 0 ; i < n ; ++i)
{
long long x , y ;
cin>>x>>y ;
vp.push_back({x , y});
}
sort(vp.begin() , vp.end());
long long ans = 0 ;
for(long long i = 0 ; i < n ; ++i)
{
long long MAX = 0 , MIN = 1e18 , sum = 0 ;
for(long long j = i ; j < n ; ++j)
{
MAX = max(MAX , vp[j].first);
MIN = min(MIN , vp[j].first);
sum += vp[j].second ;
ans = max(ans , sum - (MAX - MIN)) ;
}
}
return cout<<ans , 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
2 ms |
536 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
3 ms |
588 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Correct |
2 ms |
588 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
2 ms |
536 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
3 ms |
588 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Correct |
2 ms |
588 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
716 KB |
Output is correct |
16 |
Correct |
3 ms |
772 KB |
Output is correct |
17 |
Correct |
3 ms |
968 KB |
Output is correct |
18 |
Correct |
2 ms |
968 KB |
Output is correct |
19 |
Correct |
2 ms |
968 KB |
Output is correct |
20 |
Correct |
2 ms |
968 KB |
Output is correct |
21 |
Correct |
3 ms |
968 KB |
Output is correct |
22 |
Correct |
3 ms |
968 KB |
Output is correct |
23 |
Correct |
3 ms |
968 KB |
Output is correct |
24 |
Correct |
3 ms |
968 KB |
Output is correct |
25 |
Correct |
3 ms |
968 KB |
Output is correct |
26 |
Correct |
3 ms |
968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
2 ms |
536 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
3 ms |
588 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Correct |
2 ms |
588 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
716 KB |
Output is correct |
16 |
Correct |
3 ms |
772 KB |
Output is correct |
17 |
Correct |
3 ms |
968 KB |
Output is correct |
18 |
Correct |
2 ms |
968 KB |
Output is correct |
19 |
Correct |
2 ms |
968 KB |
Output is correct |
20 |
Correct |
2 ms |
968 KB |
Output is correct |
21 |
Correct |
3 ms |
968 KB |
Output is correct |
22 |
Correct |
3 ms |
968 KB |
Output is correct |
23 |
Correct |
3 ms |
968 KB |
Output is correct |
24 |
Correct |
3 ms |
968 KB |
Output is correct |
25 |
Correct |
3 ms |
968 KB |
Output is correct |
26 |
Correct |
3 ms |
968 KB |
Output is correct |
27 |
Correct |
47 ms |
1208 KB |
Output is correct |
28 |
Correct |
31 ms |
1336 KB |
Output is correct |
29 |
Correct |
33 ms |
1468 KB |
Output is correct |
30 |
Correct |
33 ms |
1596 KB |
Output is correct |
31 |
Correct |
36 ms |
1724 KB |
Output is correct |
32 |
Correct |
52 ms |
1852 KB |
Output is correct |
33 |
Correct |
36 ms |
1980 KB |
Output is correct |
34 |
Correct |
34 ms |
2112 KB |
Output is correct |
35 |
Correct |
32 ms |
2236 KB |
Output is correct |
36 |
Correct |
29 ms |
2412 KB |
Output is correct |
37 |
Correct |
29 ms |
2492 KB |
Output is correct |
38 |
Correct |
36 ms |
2668 KB |
Output is correct |
39 |
Correct |
31 ms |
2748 KB |
Output is correct |
40 |
Correct |
31 ms |
2876 KB |
Output is correct |
41 |
Correct |
32 ms |
3004 KB |
Output is correct |
42 |
Correct |
33 ms |
3128 KB |
Output is correct |
43 |
Correct |
31 ms |
3256 KB |
Output is correct |
44 |
Correct |
31 ms |
3384 KB |
Output is correct |
45 |
Correct |
32 ms |
3512 KB |
Output is correct |
46 |
Correct |
37 ms |
3644 KB |
Output is correct |
47 |
Correct |
30 ms |
3768 KB |
Output is correct |
48 |
Correct |
29 ms |
3896 KB |
Output is correct |
49 |
Correct |
30 ms |
4024 KB |
Output is correct |
50 |
Correct |
30 ms |
4152 KB |
Output is correct |
51 |
Correct |
35 ms |
4280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
2 ms |
536 KB |
Output is correct |
6 |
Correct |
2 ms |
568 KB |
Output is correct |
7 |
Correct |
3 ms |
588 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Correct |
2 ms |
588 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
692 KB |
Output is correct |
15 |
Correct |
2 ms |
716 KB |
Output is correct |
16 |
Correct |
3 ms |
772 KB |
Output is correct |
17 |
Correct |
3 ms |
968 KB |
Output is correct |
18 |
Correct |
2 ms |
968 KB |
Output is correct |
19 |
Correct |
2 ms |
968 KB |
Output is correct |
20 |
Correct |
2 ms |
968 KB |
Output is correct |
21 |
Correct |
3 ms |
968 KB |
Output is correct |
22 |
Correct |
3 ms |
968 KB |
Output is correct |
23 |
Correct |
3 ms |
968 KB |
Output is correct |
24 |
Correct |
3 ms |
968 KB |
Output is correct |
25 |
Correct |
3 ms |
968 KB |
Output is correct |
26 |
Correct |
3 ms |
968 KB |
Output is correct |
27 |
Correct |
47 ms |
1208 KB |
Output is correct |
28 |
Correct |
31 ms |
1336 KB |
Output is correct |
29 |
Correct |
33 ms |
1468 KB |
Output is correct |
30 |
Correct |
33 ms |
1596 KB |
Output is correct |
31 |
Correct |
36 ms |
1724 KB |
Output is correct |
32 |
Correct |
52 ms |
1852 KB |
Output is correct |
33 |
Correct |
36 ms |
1980 KB |
Output is correct |
34 |
Correct |
34 ms |
2112 KB |
Output is correct |
35 |
Correct |
32 ms |
2236 KB |
Output is correct |
36 |
Correct |
29 ms |
2412 KB |
Output is correct |
37 |
Correct |
29 ms |
2492 KB |
Output is correct |
38 |
Correct |
36 ms |
2668 KB |
Output is correct |
39 |
Correct |
31 ms |
2748 KB |
Output is correct |
40 |
Correct |
31 ms |
2876 KB |
Output is correct |
41 |
Correct |
32 ms |
3004 KB |
Output is correct |
42 |
Correct |
33 ms |
3128 KB |
Output is correct |
43 |
Correct |
31 ms |
3256 KB |
Output is correct |
44 |
Correct |
31 ms |
3384 KB |
Output is correct |
45 |
Correct |
32 ms |
3512 KB |
Output is correct |
46 |
Correct |
37 ms |
3644 KB |
Output is correct |
47 |
Correct |
30 ms |
3768 KB |
Output is correct |
48 |
Correct |
29 ms |
3896 KB |
Output is correct |
49 |
Correct |
30 ms |
4024 KB |
Output is correct |
50 |
Correct |
30 ms |
4152 KB |
Output is correct |
51 |
Correct |
35 ms |
4280 KB |
Output is correct |
52 |
Execution timed out |
1052 ms |
24880 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |