#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,m,a,b,c,cnt,g,f,d,e,cvp,k;
pair<ll,ll> dizi[100005];
int fark[100005];
string s;
int main()
{
cin>>n;
for (int i=0;i<n;i++)
cin>>dizi[i].first>>dizi[i].second;
sort(dizi,dizi+n);
ll mx=0;
ll toplam=dizi[n-1].second;
ll kntrl=dizi[n-1].first;
ll cvp=toplam;
for (int i=n-2;i>=0;i--)
{
toplam+=dizi[i].second-(kntrl-dizi[i].first);
toplam=max(toplam,dizi[i].second);
kntrl=dizi[i].first;
cvp=max(cvp,toplam);
}
cout<<cvp;
return 0;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:17:8: warning: unused variable 'mx' [-Wunused-variable]
17 | ll mx=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 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 |
204 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 |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 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 |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 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 |
204 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 |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 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 |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
5 ms |
460 KB |
Output is correct |
28 |
Correct |
6 ms |
460 KB |
Output is correct |
29 |
Correct |
6 ms |
460 KB |
Output is correct |
30 |
Correct |
6 ms |
500 KB |
Output is correct |
31 |
Correct |
7 ms |
456 KB |
Output is correct |
32 |
Correct |
6 ms |
460 KB |
Output is correct |
33 |
Correct |
6 ms |
460 KB |
Output is correct |
34 |
Correct |
7 ms |
480 KB |
Output is correct |
35 |
Correct |
6 ms |
480 KB |
Output is correct |
36 |
Correct |
6 ms |
444 KB |
Output is correct |
37 |
Correct |
6 ms |
460 KB |
Output is correct |
38 |
Correct |
8 ms |
460 KB |
Output is correct |
39 |
Correct |
8 ms |
504 KB |
Output is correct |
40 |
Correct |
6 ms |
440 KB |
Output is correct |
41 |
Correct |
9 ms |
492 KB |
Output is correct |
42 |
Correct |
7 ms |
460 KB |
Output is correct |
43 |
Correct |
8 ms |
412 KB |
Output is correct |
44 |
Correct |
6 ms |
460 KB |
Output is correct |
45 |
Correct |
6 ms |
448 KB |
Output is correct |
46 |
Correct |
6 ms |
460 KB |
Output is correct |
47 |
Correct |
6 ms |
440 KB |
Output is correct |
48 |
Correct |
6 ms |
460 KB |
Output is correct |
49 |
Correct |
6 ms |
460 KB |
Output is correct |
50 |
Correct |
7 ms |
552 KB |
Output is correct |
51 |
Correct |
6 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 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 |
204 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 |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 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 |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
5 ms |
460 KB |
Output is correct |
28 |
Correct |
6 ms |
460 KB |
Output is correct |
29 |
Correct |
6 ms |
460 KB |
Output is correct |
30 |
Correct |
6 ms |
500 KB |
Output is correct |
31 |
Correct |
7 ms |
456 KB |
Output is correct |
32 |
Correct |
6 ms |
460 KB |
Output is correct |
33 |
Correct |
6 ms |
460 KB |
Output is correct |
34 |
Correct |
7 ms |
480 KB |
Output is correct |
35 |
Correct |
6 ms |
480 KB |
Output is correct |
36 |
Correct |
6 ms |
444 KB |
Output is correct |
37 |
Correct |
6 ms |
460 KB |
Output is correct |
38 |
Correct |
8 ms |
460 KB |
Output is correct |
39 |
Correct |
8 ms |
504 KB |
Output is correct |
40 |
Correct |
6 ms |
440 KB |
Output is correct |
41 |
Correct |
9 ms |
492 KB |
Output is correct |
42 |
Correct |
7 ms |
460 KB |
Output is correct |
43 |
Correct |
8 ms |
412 KB |
Output is correct |
44 |
Correct |
6 ms |
460 KB |
Output is correct |
45 |
Correct |
6 ms |
448 KB |
Output is correct |
46 |
Correct |
6 ms |
460 KB |
Output is correct |
47 |
Correct |
6 ms |
440 KB |
Output is correct |
48 |
Correct |
6 ms |
460 KB |
Output is correct |
49 |
Correct |
6 ms |
460 KB |
Output is correct |
50 |
Correct |
7 ms |
552 KB |
Output is correct |
51 |
Correct |
6 ms |
508 KB |
Output is correct |
52 |
Incorrect |
101 ms |
2636 KB |
Output isn't correct |
53 |
Halted |
0 ms |
0 KB |
- |