# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211944 | Harry464 | Art Exhibition (JOI18_art) | C++14 | 5 ms | 256 KiB |
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 <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long
int main() {
ll n;
cin >> n;
vector <pair <ll,ll> > a(n);
for (int i = 0; i < n; i++)
cin >> a[i].first >> a[i].second;
sort(a.begin(),a.end());
ll max_so_far = -100000000000000001, max_ending_here = 0, start =0, end = 0, s=0;
for (int i=0; i< n; i++ )
{
max_ending_here += a[i].second;
if (i > 0)
max_ending_here -= a[i].first - a[i-1].first;
if (max_so_far < max_ending_here)
{
max_so_far = max_ending_here;
start = s;
end = i;
}
if (max_ending_here < 0)
{
max_ending_here = 0;
s = i + 1;
}
}
cout << max_so_far << endl;
}
Compilation message (stderr)
# | 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... |