# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55911 | YaDon4ick | Art Exhibition (JOI18_art) | C++14 | 552 ms | 132808 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.
//By Don4ick
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234
const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};
using namespace std;
int main()
{
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
//cout.tie(NULL);
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
int n;
scanf("%d", &n);
vector < pair < ll, ll > > a(n);
for (int i = 0; i < n; i++)
scanf("%lld%lld", &a[i].first, &a[i].second);
sort(all(a));
ll ans = 0, cur = 0;
set < ll > st;
for (int i = 0; i < n; i++)
{
st.insert(a[i].first - cur);
cur += a[i].second;
ans = max(ans, cur - a[i].first + (*st.rbegin()));
}
cout << ans << endl;
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... |