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;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define int ll
int32_t main(){
FAST
int n; cin >> n;
vector<pair<int, int> > arr(n + 1);
arr[0] = {0, 0};
for(int i = 1; i <= n; i++){
cin >> arr[i].first >> arr[i].second;
}
sort(arr.begin(), arr.end());
for(int i = 1; i <= n; i++){
arr[i].second += arr[i - 1].second;
}
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = i; j <= n; j++){
ans = max(ans, arr[j].second - arr[i - 1].second - arr[j].first + arr[i].first);
}
}
cout << ans << endl;
return 0;
}
# | 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... |