# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127316 | TienDungz | Art Exhibition (JOI18_art) | C++14 | 5 ms | 760 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>
#define int long long
#pragma O3
#pragma Ofast
#pragma O3("optimize")
using namespace std;
typedef pair<int,int> ii;
int n,u,v;
vector<ii> adj;
int tmp=INT_MIN,res=INT_MIN,sum=0;
signed main()
{
ios_base::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>u>>v;
adj.push_back(ii(u,v));
sum+=v;
}
sort(adj.begin(),adj.end());
for(int i=0;i<n;i++)
{
tmp=max(tmp,adj[i].first-sum);
sum+=adj[i].second;
res=max(res,sum+tmp-adj[i].first);
}
cout<<res;
}
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... |