This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
map<int,int> mp;
int n; cin >> n;
for(int i = 1 ; i <= n ; ++i) {
int a; cin >> a;
int b; cin >> b;
mp[a] += b;
}
int sum = 0;
int Min = 0;
int ans = 0;
for(auto it : mp) {
Min = min(Min,sum - it.first); sum += it.second;
ans = max(ans,sum - it.first - Min);
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |