#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
ll n, cevap = 0;
cin >> n;
vector<pair<ll, ll>> vec(n);
for(int i = 0; i < n; i++)
cin >> vec[i].first >> vec[i].second;
sort(vec.begin(), vec.end());
for(int l = 0; l < n; l++)
{
ll sum = 0, mx = 0, mn = 1e16;
for(int r = l; r < n; r++)
{
sum += vec[r].second;
mn = min(mn, vec[r].first);
mx = max(mx, vec[r].first);
cevap = max(cevap, sum - (mx - mn));
}
}
cout << cevap << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
316 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
316 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
316 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
316 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
316 KB |
Output is correct |
27 |
Correct |
27 ms |
524 KB |
Output is correct |
28 |
Correct |
25 ms |
520 KB |
Output is correct |
29 |
Correct |
23 ms |
460 KB |
Output is correct |
30 |
Correct |
25 ms |
588 KB |
Output is correct |
31 |
Correct |
23 ms |
460 KB |
Output is correct |
32 |
Correct |
28 ms |
504 KB |
Output is correct |
33 |
Correct |
27 ms |
460 KB |
Output is correct |
34 |
Correct |
26 ms |
460 KB |
Output is correct |
35 |
Correct |
23 ms |
460 KB |
Output is correct |
36 |
Correct |
22 ms |
460 KB |
Output is correct |
37 |
Correct |
23 ms |
460 KB |
Output is correct |
38 |
Correct |
24 ms |
520 KB |
Output is correct |
39 |
Correct |
25 ms |
508 KB |
Output is correct |
40 |
Correct |
23 ms |
516 KB |
Output is correct |
41 |
Correct |
25 ms |
460 KB |
Output is correct |
42 |
Correct |
26 ms |
460 KB |
Output is correct |
43 |
Correct |
24 ms |
460 KB |
Output is correct |
44 |
Correct |
25 ms |
516 KB |
Output is correct |
45 |
Correct |
23 ms |
516 KB |
Output is correct |
46 |
Correct |
22 ms |
520 KB |
Output is correct |
47 |
Correct |
23 ms |
524 KB |
Output is correct |
48 |
Correct |
23 ms |
448 KB |
Output is correct |
49 |
Correct |
23 ms |
460 KB |
Output is correct |
50 |
Correct |
23 ms |
460 KB |
Output is correct |
51 |
Correct |
24 ms |
520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
316 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
316 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
316 KB |
Output is correct |
27 |
Correct |
27 ms |
524 KB |
Output is correct |
28 |
Correct |
25 ms |
520 KB |
Output is correct |
29 |
Correct |
23 ms |
460 KB |
Output is correct |
30 |
Correct |
25 ms |
588 KB |
Output is correct |
31 |
Correct |
23 ms |
460 KB |
Output is correct |
32 |
Correct |
28 ms |
504 KB |
Output is correct |
33 |
Correct |
27 ms |
460 KB |
Output is correct |
34 |
Correct |
26 ms |
460 KB |
Output is correct |
35 |
Correct |
23 ms |
460 KB |
Output is correct |
36 |
Correct |
22 ms |
460 KB |
Output is correct |
37 |
Correct |
23 ms |
460 KB |
Output is correct |
38 |
Correct |
24 ms |
520 KB |
Output is correct |
39 |
Correct |
25 ms |
508 KB |
Output is correct |
40 |
Correct |
23 ms |
516 KB |
Output is correct |
41 |
Correct |
25 ms |
460 KB |
Output is correct |
42 |
Correct |
26 ms |
460 KB |
Output is correct |
43 |
Correct |
24 ms |
460 KB |
Output is correct |
44 |
Correct |
25 ms |
516 KB |
Output is correct |
45 |
Correct |
23 ms |
516 KB |
Output is correct |
46 |
Correct |
22 ms |
520 KB |
Output is correct |
47 |
Correct |
23 ms |
524 KB |
Output is correct |
48 |
Correct |
23 ms |
448 KB |
Output is correct |
49 |
Correct |
23 ms |
460 KB |
Output is correct |
50 |
Correct |
23 ms |
460 KB |
Output is correct |
51 |
Correct |
24 ms |
520 KB |
Output is correct |
52 |
Execution timed out |
1085 ms |
20664 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |