# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699548 | Galal012 | Art Exhibition (JOI18_art) | C++17 | 1 ms | 212 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 <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
signed main()
{
IOS;
int n, ans = 0, l = 1, r = 1, cur = -1;
cin >> n;
pair <int, int> pr[n+1];
pr[0].first = pr[0].second = 0;
for (int i = 1; i <= n; i++)
{
cin >> pr[i].first >> pr[i].second;
ans = max(ans, pr[i].second);
}
sort(pr, pr+n+1);
for (int i = 1; i <= n; i++)
pr[i].second += pr[i-1].second;
while (l <= n && r <= n)
{
cout << l << " " << r << "\n";
int tot = pr[r].second - pr[l-1].second;
int dif = pr[r].first-pr[l].first;
ans = max(ans, tot-dif);
if (l == r)
{
cur = pr[r].second-pr[l-1].second;
r++;
}
else if (r == n)
l++;
else
{
int n_tot = pr[r+1].second - pr[l-1].second;
int n_dif = pr[r+1].first-pr[l].first;
if (n_tot - n_dif >= tot-dif)
{
cur = n_tot-n_dif;
r++;
}
else
{
l++;
cur = (pr[r].second - pr[l-1].second) - (pr[r].first-pr[l].first);
}
}
}
cout << ans;
return 0;
}
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... |