#include <bits/stdc++.h>
using namespace std;
#define maxn 500010
#define ll long long
#define pll pair<ll, ll>
vector<pll> stuff;
int N;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N;
ll a, b;
for (int i = 0; i < N; i++) {
cin >> a >> b;
stuff.push_back(pll(a, b));
}
sort(stuff.begin(), stuff.end());
ll ans = 0LL;
ll cbest = 0;
ll lastval = stuff[0].first;
ll cspot, cnum;
for (int i = 0; i < N; i++) {
cspot = stuff[i].first;
cnum = stuff[i].second;
cbest = max(cnum, cnum + cbest - (cspot - lastval));
lastval = cspot;
ans = max(ans, cbest);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
3 ms |
580 KB |
Output is correct |
8 |
Correct |
2 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
3 ms |
580 KB |
Output is correct |
8 |
Correct |
2 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
26 ms |
588 KB |
Output is correct |
13 |
Correct |
3 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
3 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
724 KB |
Output is correct |
18 |
Correct |
3 ms |
724 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
2 ms |
740 KB |
Output is correct |
21 |
Correct |
2 ms |
740 KB |
Output is correct |
22 |
Correct |
2 ms |
740 KB |
Output is correct |
23 |
Correct |
2 ms |
744 KB |
Output is correct |
24 |
Correct |
2 ms |
744 KB |
Output is correct |
25 |
Correct |
3 ms |
744 KB |
Output is correct |
26 |
Correct |
3 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
3 ms |
580 KB |
Output is correct |
8 |
Correct |
2 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
26 ms |
588 KB |
Output is correct |
13 |
Correct |
3 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
3 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
724 KB |
Output is correct |
18 |
Correct |
3 ms |
724 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
2 ms |
740 KB |
Output is correct |
21 |
Correct |
2 ms |
740 KB |
Output is correct |
22 |
Correct |
2 ms |
740 KB |
Output is correct |
23 |
Correct |
2 ms |
744 KB |
Output is correct |
24 |
Correct |
2 ms |
744 KB |
Output is correct |
25 |
Correct |
3 ms |
744 KB |
Output is correct |
26 |
Correct |
3 ms |
744 KB |
Output is correct |
27 |
Correct |
4 ms |
764 KB |
Output is correct |
28 |
Correct |
30 ms |
764 KB |
Output is correct |
29 |
Correct |
5 ms |
800 KB |
Output is correct |
30 |
Correct |
7 ms |
800 KB |
Output is correct |
31 |
Correct |
6 ms |
800 KB |
Output is correct |
32 |
Correct |
5 ms |
800 KB |
Output is correct |
33 |
Correct |
5 ms |
800 KB |
Output is correct |
34 |
Correct |
5 ms |
800 KB |
Output is correct |
35 |
Correct |
5 ms |
800 KB |
Output is correct |
36 |
Correct |
5 ms |
800 KB |
Output is correct |
37 |
Correct |
3 ms |
800 KB |
Output is correct |
38 |
Correct |
5 ms |
832 KB |
Output is correct |
39 |
Correct |
5 ms |
832 KB |
Output is correct |
40 |
Correct |
6 ms |
832 KB |
Output is correct |
41 |
Correct |
5 ms |
832 KB |
Output is correct |
42 |
Correct |
6 ms |
832 KB |
Output is correct |
43 |
Correct |
4 ms |
832 KB |
Output is correct |
44 |
Correct |
5 ms |
832 KB |
Output is correct |
45 |
Correct |
4 ms |
832 KB |
Output is correct |
46 |
Correct |
4 ms |
832 KB |
Output is correct |
47 |
Correct |
4 ms |
832 KB |
Output is correct |
48 |
Correct |
4 ms |
832 KB |
Output is correct |
49 |
Correct |
5 ms |
832 KB |
Output is correct |
50 |
Correct |
5 ms |
832 KB |
Output is correct |
51 |
Correct |
4 ms |
832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
3 ms |
580 KB |
Output is correct |
8 |
Correct |
2 ms |
580 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
26 ms |
588 KB |
Output is correct |
13 |
Correct |
3 ms |
588 KB |
Output is correct |
14 |
Correct |
4 ms |
588 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
3 ms |
588 KB |
Output is correct |
17 |
Correct |
3 ms |
724 KB |
Output is correct |
18 |
Correct |
3 ms |
724 KB |
Output is correct |
19 |
Correct |
2 ms |
724 KB |
Output is correct |
20 |
Correct |
2 ms |
740 KB |
Output is correct |
21 |
Correct |
2 ms |
740 KB |
Output is correct |
22 |
Correct |
2 ms |
740 KB |
Output is correct |
23 |
Correct |
2 ms |
744 KB |
Output is correct |
24 |
Correct |
2 ms |
744 KB |
Output is correct |
25 |
Correct |
3 ms |
744 KB |
Output is correct |
26 |
Correct |
3 ms |
744 KB |
Output is correct |
27 |
Correct |
4 ms |
764 KB |
Output is correct |
28 |
Correct |
30 ms |
764 KB |
Output is correct |
29 |
Correct |
5 ms |
800 KB |
Output is correct |
30 |
Correct |
7 ms |
800 KB |
Output is correct |
31 |
Correct |
6 ms |
800 KB |
Output is correct |
32 |
Correct |
5 ms |
800 KB |
Output is correct |
33 |
Correct |
5 ms |
800 KB |
Output is correct |
34 |
Correct |
5 ms |
800 KB |
Output is correct |
35 |
Correct |
5 ms |
800 KB |
Output is correct |
36 |
Correct |
5 ms |
800 KB |
Output is correct |
37 |
Correct |
3 ms |
800 KB |
Output is correct |
38 |
Correct |
5 ms |
832 KB |
Output is correct |
39 |
Correct |
5 ms |
832 KB |
Output is correct |
40 |
Correct |
6 ms |
832 KB |
Output is correct |
41 |
Correct |
5 ms |
832 KB |
Output is correct |
42 |
Correct |
6 ms |
832 KB |
Output is correct |
43 |
Correct |
4 ms |
832 KB |
Output is correct |
44 |
Correct |
5 ms |
832 KB |
Output is correct |
45 |
Correct |
4 ms |
832 KB |
Output is correct |
46 |
Correct |
4 ms |
832 KB |
Output is correct |
47 |
Correct |
4 ms |
832 KB |
Output is correct |
48 |
Correct |
4 ms |
832 KB |
Output is correct |
49 |
Correct |
5 ms |
832 KB |
Output is correct |
50 |
Correct |
5 ms |
832 KB |
Output is correct |
51 |
Correct |
4 ms |
832 KB |
Output is correct |
52 |
Correct |
236 ms |
8936 KB |
Output is correct |
53 |
Correct |
235 ms |
8936 KB |
Output is correct |
54 |
Correct |
315 ms |
8936 KB |
Output is correct |
55 |
Correct |
273 ms |
8956 KB |
Output is correct |
56 |
Correct |
277 ms |
8956 KB |
Output is correct |
57 |
Correct |
285 ms |
9104 KB |
Output is correct |
58 |
Correct |
252 ms |
21336 KB |
Output is correct |
59 |
Correct |
283 ms |
33932 KB |
Output is correct |
60 |
Correct |
275 ms |
46648 KB |
Output is correct |
61 |
Correct |
277 ms |
59172 KB |
Output is correct |
62 |
Correct |
252 ms |
71864 KB |
Output is correct |
63 |
Correct |
239 ms |
84724 KB |
Output is correct |
64 |
Correct |
252 ms |
97424 KB |
Output is correct |
65 |
Correct |
286 ms |
109840 KB |
Output is correct |
66 |
Correct |
244 ms |
122660 KB |
Output is correct |
67 |
Correct |
245 ms |
135276 KB |
Output is correct |
68 |
Correct |
500 ms |
148040 KB |
Output is correct |