Submission #699435

#TimeUsernameProblemLanguageResultExecution timeMemory
699435Ahmed_SolymanArt Exhibition (JOI18_art)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #include <ext/rope> using namespace std; using namespace __gnu_cxx; #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") //-------------------------------------------------------------// typedef long long ll; typedef unsigned long long ull; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define PI acos(-1) #define lb lower_bound #define ub upper_bound #define endl '\n' #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sum_to(n) (n*(n+1))/2 #define pb push_back #define pf push_front #define sz size() #define fil(arr,x) memset(arr,x,sizeof(arr)) const ll mod=1e9+7; int dx[8]={0,1,0,-1,1,1,-1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; //-------------------------------------------------------------// ll lcm(ll a,ll b) { return (max(a,b)/__gcd(a,b))*min(a,b); } void person_bool(bool x) { cout<<(x?"YES":"NO")<<endl; } int n; vector<pair<ll,ll>>arr; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); fast cin>>n; arr.resize(n+1); for(int i=0;i<n;i++){ cin>>arr[i].first>>arr[i].second; } sort(all(arr)); ll ans=0; ll sum=0; for(int i=0;i<n;i++){ ans=max(ans,arr[i].second); } vector<ll>v(n); for(int i=1;i<n;i++){ sum+=arr[i].second; v[i]=sum-(arr[i].first-arr[0].first); ans=max(ans,v[i]); } for(int i=n-2;i>=0;i--){ v[i]=max(v[i],v[i+1]); } ll x=0; for(int i=1;i<n;i++){ x-=arr[i-1].second; x+=arr[i].first-arr[i-1].first; ans=max(ans,v[i]+x); } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...