Submission #41074

#TimeUsernameProblemLanguageResultExecution timeMemory
41074zscoderArt Exhibition (JOI18_art)C++14
100 / 100
259 ms16500 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<int>::iterator sit; typedef map<int,int>::iterator mit; typedef vector<int>::iterator vit; ll a[511111]; ll b[511111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<pair<ll,ll> > vec; for(int i=0;i<n;i++) { ll x,y; cin>>x>>y; vec.pb(mp(x,y)); } sort(vec.begin(),vec.end()); for(int i=1;i<=n;i++) { a[i] = vec[i-1].fi; b[i] = vec[i-1].se; } for(int i=1;i<=n;i++) { b[i]+=b[i-1]; } ll mini = b[0] - a[1]; ll ans = 0; for(int i=1;i<=n;i++) { ans = max(ans, b[i]-a[i]-mini); if(i<n) mini=min(mini,b[i]-a[i+1]); } cout<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...