제출 #928516

#제출 시각아이디문제언어결과실행 시간메모리
928516ting39Art Exhibition (JOI18_art)C++17
100 / 100
412 ms21060 KiB
#include<bits/stdc++.h> #define int long long #define pii pair<int,int> #define F first #define S second using namespace std; signed main(){ int n; cin>>n; vector<pii> v(n); for(auto &i:v) cin>>i.F>>i.S; sort(v.begin(),v.end(),[](auto i,auto j){ return i.F<j.F; }); int ans=0; int dif=0,mxdif=0,tmp=v[0].S; for(int i=1;i<n;i++){ dif+=v[i].F-v[i-1].F; dif-=v[i-1].S; mxdif=max(mxdif,dif); tmp+=v[i].S-(v[i].F-v[i-1].F); ans=max(ans,tmp+mxdif); } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...