| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355449 | po_rag526 | Art Exhibition (JOI18_art) | C++20 | 103 ms | 12184 KiB |
#include <bits/stdc++.h>
#define pb push_back
#define se second
#define fi first
#define all(x) (x).begin(), (x).end()
#define el "\n"
#define bit(mask,i) ((mask>>i)&1)
#define vll vector <long long>
#define FOR(i, a, b) for (int i = a; i <= b; i ++)
#define REP(i, a, b) for (int i = a; i >= b; i --)
#define taskname "test"
#define int long long
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const int MAXN = 1e6+5;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPSILON = 0.000001;
// Initial function
ll add(ll x, ll y) {
x += y;
if (x >= MOD) x -= MOD;
if (x < 0) x += MOD;
return x;
}
void maximize (ll &x, ll val) {
x = max (x, val);
}
void minimize (ll &x, ll val) {
x = min (x, val);
}
ll Pow (ll x, ll y) {
int ans = 1;
while (y > 0) {
if (y & 1) ans = ans * x % MOD;
y /= 2;
x = x * x % MOD;
}
return ans;
}
// -----------------------
int n, f[MAXN];
pi a[MAXN];
void solve () {
cin >> n;
FOR (i, 1, n) cin >> a[i].fi >> a[i].se;
sort (a + 1, a + 1 + n);
int res = 0;
FOR (i, 1, n) {
f[i] = max (a[i].se, f[i - 1] + a[i].se - (a[i].fi - a[i - 1].fi));
maximize (res, f[i]);
}
cout << res;
}
signed main ()
{
if (fopen (taskname".inp", "r"))
{
freopen (taskname".inp", "r", stdin);
freopen (taskname".out", "w", stdout);
}
ios_base :: sync_with_stdio (false);
cin.tie (NULL);
cout.tie (NULL);
clock_t start = clock();
solve ();
std::cerr << "Time elapsed: " << clock() - start << " ms\n";
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... | ||||
