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;
int n;
pair<long long, int> pa[500001];
long long maxx = 0;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) cin >> pa[i].first >> pa[i].second;
sort(pa + 1, pa + n + 1);
for (int i = 1; i <= n; i++)
{
long long tong = 0;
for (int j = i; j <= n; j++)
{
tong += pa[j].second;
maxx = max(maxx, tong - (pa[j].first - pa[i].first));
};
};
cout << maxx;
}
# | 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... |