#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 5e5+5;
ll segt[4*N], lazy[4*N];
int n;
void updlazy(int pos, int siz)
{
if(lazy[pos]!=0)
{
segt[pos]+=lazy[pos];
if(siz!=1)
lazy[pos*2]+=lazy[pos],
lazy[pos*2+1]+=lazy[pos];
lazy[pos]=0;
}
}
void upd(int lb, int rb, ll val, int l = 1, int r = n, int pos = 1)
{
updlazy(pos,r-l+1);
if(rb<l||r<lb)
return;
if(lb<=l&&r<=rb)
lazy[pos]+=val,
updlazy(pos,r-l+1);
else
{
int mid = (l+r)/2;
upd(lb,rb,val,l,mid,pos*2);
upd(lb,rb,val,mid+1,r,pos*2+1);
segt[pos]=max(segt[pos*2],segt[pos*2+1]);
}
}
int main()
{
fio
// ifstream cin("in.in");
cin >> n;
pair<ll,int> p[n+1];
for(int i = 1;i<=n;i++)
cin >> p[i].fi >> p[i].se;
sort(p+1,p+1+n);
p[0]={0,0};
ll res = 0;
for(int i = 1;i<=n;i++)
{
upd(i,i,p[i].se);
upd(1,i-1,-(p[i].fi-p[i-1].fi)+p[i].se);
updlazy(1,n);
res=max(res,segt[1]);
}
cout << res;
// cin.close();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
4 ms |
724 KB |
Output is correct |
28 |
Correct |
4 ms |
724 KB |
Output is correct |
29 |
Correct |
3 ms |
724 KB |
Output is correct |
30 |
Correct |
3 ms |
724 KB |
Output is correct |
31 |
Correct |
5 ms |
728 KB |
Output is correct |
32 |
Correct |
4 ms |
736 KB |
Output is correct |
33 |
Correct |
4 ms |
724 KB |
Output is correct |
34 |
Correct |
4 ms |
724 KB |
Output is correct |
35 |
Correct |
4 ms |
724 KB |
Output is correct |
36 |
Correct |
4 ms |
724 KB |
Output is correct |
37 |
Correct |
4 ms |
724 KB |
Output is correct |
38 |
Correct |
3 ms |
776 KB |
Output is correct |
39 |
Correct |
4 ms |
724 KB |
Output is correct |
40 |
Correct |
3 ms |
732 KB |
Output is correct |
41 |
Correct |
4 ms |
788 KB |
Output is correct |
42 |
Correct |
4 ms |
736 KB |
Output is correct |
43 |
Correct |
3 ms |
728 KB |
Output is correct |
44 |
Correct |
4 ms |
724 KB |
Output is correct |
45 |
Correct |
4 ms |
780 KB |
Output is correct |
46 |
Correct |
4 ms |
848 KB |
Output is correct |
47 |
Correct |
4 ms |
780 KB |
Output is correct |
48 |
Correct |
4 ms |
792 KB |
Output is correct |
49 |
Correct |
4 ms |
732 KB |
Output is correct |
50 |
Correct |
4 ms |
780 KB |
Output is correct |
51 |
Correct |
4 ms |
736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
4 ms |
724 KB |
Output is correct |
28 |
Correct |
4 ms |
724 KB |
Output is correct |
29 |
Correct |
3 ms |
724 KB |
Output is correct |
30 |
Correct |
3 ms |
724 KB |
Output is correct |
31 |
Correct |
5 ms |
728 KB |
Output is correct |
32 |
Correct |
4 ms |
736 KB |
Output is correct |
33 |
Correct |
4 ms |
724 KB |
Output is correct |
34 |
Correct |
4 ms |
724 KB |
Output is correct |
35 |
Correct |
4 ms |
724 KB |
Output is correct |
36 |
Correct |
4 ms |
724 KB |
Output is correct |
37 |
Correct |
4 ms |
724 KB |
Output is correct |
38 |
Correct |
3 ms |
776 KB |
Output is correct |
39 |
Correct |
4 ms |
724 KB |
Output is correct |
40 |
Correct |
3 ms |
732 KB |
Output is correct |
41 |
Correct |
4 ms |
788 KB |
Output is correct |
42 |
Correct |
4 ms |
736 KB |
Output is correct |
43 |
Correct |
3 ms |
728 KB |
Output is correct |
44 |
Correct |
4 ms |
724 KB |
Output is correct |
45 |
Correct |
4 ms |
780 KB |
Output is correct |
46 |
Correct |
4 ms |
848 KB |
Output is correct |
47 |
Correct |
4 ms |
780 KB |
Output is correct |
48 |
Correct |
4 ms |
792 KB |
Output is correct |
49 |
Correct |
4 ms |
732 KB |
Output is correct |
50 |
Correct |
4 ms |
780 KB |
Output is correct |
51 |
Correct |
4 ms |
736 KB |
Output is correct |
52 |
Correct |
363 ms |
28932 KB |
Output is correct |
53 |
Correct |
361 ms |
28748 KB |
Output is correct |
54 |
Correct |
364 ms |
28884 KB |
Output is correct |
55 |
Correct |
356 ms |
28728 KB |
Output is correct |
56 |
Correct |
362 ms |
28740 KB |
Output is correct |
57 |
Correct |
359 ms |
28740 KB |
Output is correct |
58 |
Correct |
358 ms |
28792 KB |
Output is correct |
59 |
Correct |
354 ms |
28828 KB |
Output is correct |
60 |
Correct |
372 ms |
28740 KB |
Output is correct |
61 |
Correct |
359 ms |
28748 KB |
Output is correct |
62 |
Correct |
353 ms |
28804 KB |
Output is correct |
63 |
Correct |
357 ms |
28996 KB |
Output is correct |
64 |
Correct |
366 ms |
28876 KB |
Output is correct |
65 |
Correct |
365 ms |
28820 KB |
Output is correct |
66 |
Correct |
357 ms |
28812 KB |
Output is correct |
67 |
Correct |
360 ms |
28748 KB |
Output is correct |
68 |
Correct |
353 ms |
28992 KB |
Output is correct |