#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,ta,tb,tem,has;
pair<ll,ll> a[505050];
vector<ll> v;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>ta>>tb;
a[i]=mp(ta,tb);
}
sort(a+1,a+1+n);
for(i=1;i<=n;i++)
{
v.pb(-a[i].se);
v.pb(a[i].se);
if(i<n)
v.pb((a[i+1].se)-(a[i+1].fi-a[i].fi));
}
for(i=0;i<v.size();i++)
{
tem+=v[i];
tem=max(tem,0LL);
has=max(has,tem);
}
cout<<has<<"\n";
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:28:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<v.size();i++)
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
584 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
832 KB |
Output is correct |
8 |
Correct |
2 ms |
832 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
856 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
584 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
832 KB |
Output is correct |
8 |
Correct |
2 ms |
832 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
856 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
12 |
Correct |
2 ms |
856 KB |
Output is correct |
13 |
Correct |
2 ms |
856 KB |
Output is correct |
14 |
Correct |
3 ms |
856 KB |
Output is correct |
15 |
Correct |
2 ms |
856 KB |
Output is correct |
16 |
Correct |
2 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
856 KB |
Output is correct |
18 |
Correct |
2 ms |
872 KB |
Output is correct |
19 |
Correct |
2 ms |
896 KB |
Output is correct |
20 |
Correct |
3 ms |
904 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
2 ms |
932 KB |
Output is correct |
23 |
Correct |
2 ms |
932 KB |
Output is correct |
24 |
Correct |
2 ms |
936 KB |
Output is correct |
25 |
Correct |
3 ms |
936 KB |
Output is correct |
26 |
Correct |
3 ms |
988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
584 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
832 KB |
Output is correct |
8 |
Correct |
2 ms |
832 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
856 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
12 |
Correct |
2 ms |
856 KB |
Output is correct |
13 |
Correct |
2 ms |
856 KB |
Output is correct |
14 |
Correct |
3 ms |
856 KB |
Output is correct |
15 |
Correct |
2 ms |
856 KB |
Output is correct |
16 |
Correct |
2 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
856 KB |
Output is correct |
18 |
Correct |
2 ms |
872 KB |
Output is correct |
19 |
Correct |
2 ms |
896 KB |
Output is correct |
20 |
Correct |
3 ms |
904 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
2 ms |
932 KB |
Output is correct |
23 |
Correct |
2 ms |
932 KB |
Output is correct |
24 |
Correct |
2 ms |
936 KB |
Output is correct |
25 |
Correct |
3 ms |
936 KB |
Output is correct |
26 |
Correct |
3 ms |
988 KB |
Output is correct |
27 |
Correct |
5 ms |
1344 KB |
Output is correct |
28 |
Correct |
6 ms |
1472 KB |
Output is correct |
29 |
Correct |
6 ms |
1600 KB |
Output is correct |
30 |
Correct |
6 ms |
1728 KB |
Output is correct |
31 |
Correct |
5 ms |
1856 KB |
Output is correct |
32 |
Correct |
6 ms |
2028 KB |
Output is correct |
33 |
Correct |
19 ms |
2076 KB |
Output is correct |
34 |
Correct |
6 ms |
2240 KB |
Output is correct |
35 |
Correct |
6 ms |
2368 KB |
Output is correct |
36 |
Correct |
6 ms |
2516 KB |
Output is correct |
37 |
Correct |
6 ms |
2624 KB |
Output is correct |
38 |
Correct |
6 ms |
2752 KB |
Output is correct |
39 |
Correct |
7 ms |
2884 KB |
Output is correct |
40 |
Correct |
5 ms |
3056 KB |
Output is correct |
41 |
Correct |
4 ms |
3264 KB |
Output is correct |
42 |
Correct |
4 ms |
3264 KB |
Output is correct |
43 |
Correct |
7 ms |
3428 KB |
Output is correct |
44 |
Correct |
6 ms |
3556 KB |
Output is correct |
45 |
Correct |
6 ms |
3676 KB |
Output is correct |
46 |
Correct |
5 ms |
3776 KB |
Output is correct |
47 |
Correct |
5 ms |
3904 KB |
Output is correct |
48 |
Correct |
6 ms |
4032 KB |
Output is correct |
49 |
Correct |
5 ms |
4160 KB |
Output is correct |
50 |
Correct |
5 ms |
4288 KB |
Output is correct |
51 |
Correct |
6 ms |
4416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
584 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
832 KB |
Output is correct |
8 |
Correct |
2 ms |
832 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
856 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
12 |
Correct |
2 ms |
856 KB |
Output is correct |
13 |
Correct |
2 ms |
856 KB |
Output is correct |
14 |
Correct |
3 ms |
856 KB |
Output is correct |
15 |
Correct |
2 ms |
856 KB |
Output is correct |
16 |
Correct |
2 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
856 KB |
Output is correct |
18 |
Correct |
2 ms |
872 KB |
Output is correct |
19 |
Correct |
2 ms |
896 KB |
Output is correct |
20 |
Correct |
3 ms |
904 KB |
Output is correct |
21 |
Correct |
3 ms |
912 KB |
Output is correct |
22 |
Correct |
2 ms |
932 KB |
Output is correct |
23 |
Correct |
2 ms |
932 KB |
Output is correct |
24 |
Correct |
2 ms |
936 KB |
Output is correct |
25 |
Correct |
3 ms |
936 KB |
Output is correct |
26 |
Correct |
3 ms |
988 KB |
Output is correct |
27 |
Correct |
5 ms |
1344 KB |
Output is correct |
28 |
Correct |
6 ms |
1472 KB |
Output is correct |
29 |
Correct |
6 ms |
1600 KB |
Output is correct |
30 |
Correct |
6 ms |
1728 KB |
Output is correct |
31 |
Correct |
5 ms |
1856 KB |
Output is correct |
32 |
Correct |
6 ms |
2028 KB |
Output is correct |
33 |
Correct |
19 ms |
2076 KB |
Output is correct |
34 |
Correct |
6 ms |
2240 KB |
Output is correct |
35 |
Correct |
6 ms |
2368 KB |
Output is correct |
36 |
Correct |
6 ms |
2516 KB |
Output is correct |
37 |
Correct |
6 ms |
2624 KB |
Output is correct |
38 |
Correct |
6 ms |
2752 KB |
Output is correct |
39 |
Correct |
7 ms |
2884 KB |
Output is correct |
40 |
Correct |
5 ms |
3056 KB |
Output is correct |
41 |
Correct |
4 ms |
3264 KB |
Output is correct |
42 |
Correct |
4 ms |
3264 KB |
Output is correct |
43 |
Correct |
7 ms |
3428 KB |
Output is correct |
44 |
Correct |
6 ms |
3556 KB |
Output is correct |
45 |
Correct |
6 ms |
3676 KB |
Output is correct |
46 |
Correct |
5 ms |
3776 KB |
Output is correct |
47 |
Correct |
5 ms |
3904 KB |
Output is correct |
48 |
Correct |
6 ms |
4032 KB |
Output is correct |
49 |
Correct |
5 ms |
4160 KB |
Output is correct |
50 |
Correct |
5 ms |
4288 KB |
Output is correct |
51 |
Correct |
6 ms |
4416 KB |
Output is correct |
52 |
Correct |
296 ms |
41244 KB |
Output is correct |
53 |
Correct |
296 ms |
53864 KB |
Output is correct |
54 |
Correct |
289 ms |
66480 KB |
Output is correct |
55 |
Correct |
332 ms |
79132 KB |
Output is correct |
56 |
Correct |
289 ms |
91772 KB |
Output is correct |
57 |
Correct |
276 ms |
104408 KB |
Output is correct |
58 |
Correct |
301 ms |
117084 KB |
Output is correct |
59 |
Correct |
291 ms |
129760 KB |
Output is correct |
60 |
Correct |
292 ms |
142492 KB |
Output is correct |
61 |
Correct |
280 ms |
155144 KB |
Output is correct |
62 |
Correct |
292 ms |
167732 KB |
Output is correct |
63 |
Correct |
328 ms |
180408 KB |
Output is correct |
64 |
Correct |
269 ms |
193008 KB |
Output is correct |
65 |
Correct |
267 ms |
205812 KB |
Output is correct |
66 |
Correct |
307 ms |
218488 KB |
Output is correct |
67 |
Correct |
258 ms |
231104 KB |
Output is correct |
68 |
Correct |
272 ms |
243796 KB |
Output is correct |