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
#define A first
#define B second
signed main(){
int n;
cin >> n;
pair<int , int> p[n+1];
for (int i = 1 ; i<=n ; i++){
int a , b;
cin >> a >> b;
p[i] = {a , b};
}
sort(p , p+n+1);
for (int i = 1 ; i<=n ; i++){
p[i].B += p[i-1].B;
}
int max = 0;
for (int l = 1 ; l<=n ; l++){
for (int r = l ; r<=n ; r++){
int x = (p[r].B-p[l-1].B) - (p[r].A-p[l].A);
if ( x > max) max = x;
}
}
cout << max << '\n';
}
# | 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... |