/***
* __ __ _ _ _
* | \/ | | | | | | |
* | \ / |_ __ | | | |_ __ | | ___ __ _____ ___ __
* | |\/| | '__| | | | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
* | | | | | _ | |__| | | | | <| | | | (_) \ V V /| | | |
* |_| |_|_| (_) \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
*
*
*/
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
#define MP make_pair
#define ii pair<ll,ll>
//#define iii pair<int,ii>
#define fi first
#define se second;
int n;
ll a[500005],b[500005],ans=0;
vector<ii> v;
int main() {
// freopen("","r",stdin);
// freopen("","w",stdout);
scanf("%d", &n);
f(i,1,n) {
scanf("%lld %lld", &a[i], &b[i]);
v.push_back(MP(a[i],b[i]));
}
sort(v.begin(),v.end());
memset(a,0,sizeof(a));
ans=-1e18;
f(i,1,n) {
a[i]=a[i-1]+v[i-1].se;
ans=max(ans,a[i]-v[i-1].fi);
}
ans+=v[0].fi;
printf("%lld", ans);
return 0;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
art.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &a[i], &b[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
4216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
4216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
4216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
4216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |