| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1281587 | dungnt | Art Exhibition (JOI18_art) | C++20 | 151 ms | 12116 KiB |
#include<bits/stdc++.h>
#define M 500004
#define ll long long
#define fi first
#define se second
using namespace std;
int n;
pair<ll, int> p[M];
ll s[M];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define name "baitap"
if(fopen(name".inp", "r"))
{
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n; i++)
cin >> p[i].fi >> p[i].se;
sort(p + 1, p + n + 1);
for(int i = 1; i <= n; i++)
s[i] = s[i - 1] + p[i].se;
ll cur = -1e18, ans = -1e18;
for(int i = 1; i <= n; i++)
{
cur = max(cur, p[i].fi - s[i - 1]);
ans = max(ans, cur + s[i] - p[i].fi);
}
cout << ans;
}
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... | ||||
