#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <set>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define vv vector
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double>
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>
using namespace std;
const int INF = 1e9;
const int MAXN = 400+5;
const int MAXK = 100+10;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vv<pll> all;
FOR(i,n){
ll a,b;
cin >> a >> b;
all.pb({a,b});
}
sort(all.begin(), all.end());
vv<ll> pref;
for(auto e : all){
if(pref.empty())pref.pb(e.ss);
else pref.pb(pref.back() + e.ss);
}
set<ll> st;
ll mx = -1e18;
for(auto e : all)mx = max(mx,e.ss);
int ptr = -1;
for(auto e : all){
st.insert(((ptr > -1)?pref[ptr]:0) - e.ff);
mx = max(mx,pref[++ptr] - e.ff - (*st.begin()));
}
cout << mx << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
252 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
252 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
424 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
252 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
424 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
632 KB |
Output is correct |
28 |
Correct |
5 ms |
760 KB |
Output is correct |
29 |
Correct |
5 ms |
632 KB |
Output is correct |
30 |
Correct |
5 ms |
632 KB |
Output is correct |
31 |
Correct |
5 ms |
632 KB |
Output is correct |
32 |
Correct |
5 ms |
760 KB |
Output is correct |
33 |
Correct |
6 ms |
760 KB |
Output is correct |
34 |
Correct |
5 ms |
632 KB |
Output is correct |
35 |
Correct |
6 ms |
760 KB |
Output is correct |
36 |
Correct |
5 ms |
632 KB |
Output is correct |
37 |
Correct |
5 ms |
632 KB |
Output is correct |
38 |
Correct |
5 ms |
760 KB |
Output is correct |
39 |
Correct |
5 ms |
760 KB |
Output is correct |
40 |
Correct |
5 ms |
632 KB |
Output is correct |
41 |
Correct |
5 ms |
632 KB |
Output is correct |
42 |
Correct |
5 ms |
760 KB |
Output is correct |
43 |
Correct |
5 ms |
632 KB |
Output is correct |
44 |
Correct |
5 ms |
632 KB |
Output is correct |
45 |
Correct |
5 ms |
732 KB |
Output is correct |
46 |
Correct |
5 ms |
632 KB |
Output is correct |
47 |
Correct |
5 ms |
760 KB |
Output is correct |
48 |
Correct |
5 ms |
632 KB |
Output is correct |
49 |
Correct |
5 ms |
632 KB |
Output is correct |
50 |
Correct |
5 ms |
632 KB |
Output is correct |
51 |
Correct |
5 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
252 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
424 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
5 ms |
632 KB |
Output is correct |
28 |
Correct |
5 ms |
760 KB |
Output is correct |
29 |
Correct |
5 ms |
632 KB |
Output is correct |
30 |
Correct |
5 ms |
632 KB |
Output is correct |
31 |
Correct |
5 ms |
632 KB |
Output is correct |
32 |
Correct |
5 ms |
760 KB |
Output is correct |
33 |
Correct |
6 ms |
760 KB |
Output is correct |
34 |
Correct |
5 ms |
632 KB |
Output is correct |
35 |
Correct |
6 ms |
760 KB |
Output is correct |
36 |
Correct |
5 ms |
632 KB |
Output is correct |
37 |
Correct |
5 ms |
632 KB |
Output is correct |
38 |
Correct |
5 ms |
760 KB |
Output is correct |
39 |
Correct |
5 ms |
760 KB |
Output is correct |
40 |
Correct |
5 ms |
632 KB |
Output is correct |
41 |
Correct |
5 ms |
632 KB |
Output is correct |
42 |
Correct |
5 ms |
760 KB |
Output is correct |
43 |
Correct |
5 ms |
632 KB |
Output is correct |
44 |
Correct |
5 ms |
632 KB |
Output is correct |
45 |
Correct |
5 ms |
732 KB |
Output is correct |
46 |
Correct |
5 ms |
632 KB |
Output is correct |
47 |
Correct |
5 ms |
760 KB |
Output is correct |
48 |
Correct |
5 ms |
632 KB |
Output is correct |
49 |
Correct |
5 ms |
632 KB |
Output is correct |
50 |
Correct |
5 ms |
632 KB |
Output is correct |
51 |
Correct |
5 ms |
760 KB |
Output is correct |
52 |
Correct |
358 ms |
35736 KB |
Output is correct |
53 |
Correct |
373 ms |
48220 KB |
Output is correct |
54 |
Correct |
390 ms |
48212 KB |
Output is correct |
55 |
Correct |
403 ms |
48464 KB |
Output is correct |
56 |
Correct |
453 ms |
48288 KB |
Output is correct |
57 |
Correct |
460 ms |
48188 KB |
Output is correct |
58 |
Correct |
418 ms |
48388 KB |
Output is correct |
59 |
Correct |
408 ms |
48216 KB |
Output is correct |
60 |
Correct |
402 ms |
48340 KB |
Output is correct |
61 |
Correct |
408 ms |
48260 KB |
Output is correct |
62 |
Correct |
393 ms |
48352 KB |
Output is correct |
63 |
Correct |
392 ms |
48272 KB |
Output is correct |
64 |
Correct |
390 ms |
48184 KB |
Output is correct |
65 |
Correct |
377 ms |
48276 KB |
Output is correct |
66 |
Correct |
367 ms |
48268 KB |
Output is correct |
67 |
Correct |
389 ms |
48340 KB |
Output is correct |
68 |
Correct |
439 ms |
48264 KB |
Output is correct |