제출 #129154

#제출 시각아이디문제언어결과실행 시간메모리
129154miguelArt Exhibition (JOI18_art)C++14
100 / 100
274 ms28792 KiB
#include<bits/stdc++.h> using namespace std; #define rc(x) return cout<<x<<endl,0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define int ll #define sz size() #define x first #define y second #define pi pair <int, int> #define pii pair <int, pi> #define vi vector <int> const ll mod = 1e9 + 7; int n, net[500004]; vector <pi> art; int mn[500004]; int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n; art.resize(n+1); for(int i=1; i<=n; i++) cin>>art[i].x>>art[i].y; art[0]={0, 0}; sort(art.begin(), art.end()); //for(int i=1; i<=n; i++) art[i].x-=art[1].x; //net[1]=art[1].y; ///cout<<endl;for(int i=1; i<=n; i++) cout<<art[i].x<<" "<<art[i].y<<endl; cout<<endl; for(int i=1; i<=n; i++) net[i]=art[i].y-(art[i].x-art[i-1].x); ///for(int i=1; i<=n; i++) cout<<net[i]<<" "; cout<<endl; for(int i=1; i<=n; i++) net[i]+=net[i-1]; ///for(int i=1; i<=n; i++) cout<<net[i]<<" "; cout<<endl; mn[n]=net[n]; for(int i=n-1; i>=1; i--) mn[i]=max(mn[i+1], net[i]); int ans=0; for(int i=1; i<=n; i++){ /*if(i==6){ dbg(mn[i]); dbg(net[i-1]); dbg(art[i].x); }*/ ans=max(ans, mn[i]-net[i-1]+art[i].x-art[i-1].x); ///cout<<ans<<" "; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...