# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116642 | roseanne_pcy | Art Exhibition (JOI18_art) | C++14 | 253 ms | 32768 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.
//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<ll, ll> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
vii pong;
const int maxn = 5e5+5;
ll qs[maxn];
ll x[maxn], y[maxn];
int main()
{
int n; scanf("%d", &n);
for(int i = 0; i< n; i++)
{
pong.pb(ii());
scanf("%lld %lld", &pong.back().X, &pong.back().Y);
}
sort(pong.begin(), pong.end());
for(int i = 1; i<= n; i++)
{
qs[i] = qs[i-1] + pong[i-1].Y;
}
for(int i = 1; i<= n; i++) x[i] = qs[i]-pong[i-1].X;
for(int i = 1; i<= n; i++) y[i] = qs[i-1]-pong[i-1].X;
//for(int i = 1; i<= n; i++) cout << x[i] << " " << y[i] << endl;
ll best = 1e18;
ll res = -1e18;
for(int i = 1; i<= n; i++)
{
best = min(best, y[i]);
res = max(res, x[i]-best);
}
printf("%lld\n", res);
}
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... |