# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108386 | KhanhDang | Art Exhibition (JOI18_art) | C++17 | 127 ms | 12164 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>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a), _b=(b); i<=_b; i++)
#define FORD(i, a, b) for(int i=(a), _b=(b); i>=_b; i--)
#define BIT(i, j) ((i>>j)&1)
#define pb push_back
#define ii pair<ll, ll>
#define pii pair<ll, ii>
#define fi first
#define se second
#define task "task"
const ll inf = 1e18;
const ll mod = 1e9+7;
const ll N = 500005;
const ll M = 50005;
ll n, s[N], ans, prefix[N], t;
ii a[N];
void solve()
{
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> a[i].fi >> a[i].se;
}
sort(a+1, a+n+1);
for(int i = 1; i <= n; i++)
{
prefix[i] = max(prefix[i-1], a[i].fi - t);
t += a[i].se;
ans = max(ans, t + prefix[i] - a[i].fi);
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen(task".INP", "r"))
{
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
solve();
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... |