# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582046 | hibiki | Art Exhibition (JOI18_art) | C++11 | 253 ms | 14188 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 pb push_back
int n;
long long a[500005],b[500005];
long long ans = 0, dp[500005];
vector<int> v;
int main()
{
scanf("%d",&n);
for(int i = 0; i < n; i++)
{
scanf("%lld %lld",&a[i],&b[i]);
v.pb(i);
}
sort(v.begin(),v.end(), [&](const int x, const int y){
return a[x] < a[y];
});
for(int i = 0; i < n; i++)
{
dp[i] = b[v[i]];
if(i)
dp[i] += max(0ll, dp[i - 1] - (a[v[i]] - a[v[i - 1]]));
ans = max(ans,dp[i]);
}
printf("%lld\n",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... |