Submission #565829

#TimeUsernameProblemLanguageResultExecution timeMemory
565829nots0fastArt Exhibition (JOI18_art)C++17
100 / 100
193 ms8840 KiB
#include <bits/stdc++.h> using namespace std; #define mp(a,b) make_pair(a,b) #define ff first #define setp(a) setprecision(a)<<fixed #define ss second #define fori(v) for(ll i=0; i<v; i++) #define forj(v) for(ll j=0; j<v; j++) #define fork(v) for(ll k=0; k<v; k++) #define forl(v) for(ll l=0; l<v; l++) #define fort(v) for(ll t=0; t<v; t++) #define forz(v) for(ll z=0; z<v; z++) #define forx(v) for(ll x=0; x<v; x++) #define fory(v) for(ll y=0; y<v; y++) #define ll long long #define pb push_back #define mt make_tuple const ll INF = 0x3f3f3f3f; const ll inf = pow(10,18); ll modulo = 998244353; void deal(){ ll n; cin>>n; vector<pair<ll, ll> > arr; fori(n){ ll ai, si; cin>>ai>>si; arr.pb(mp(ai, si)); } sort(arr.begin(), arr.end()); ll mx = -inf; ll pf = 0; ll ans = 0; for(auto& el : arr){ ll vl = pf-el.ff; mx = max(mx, -vl); pf+=el.ss; vl = pf-el.ff; ans = max(ans, vl + mx); } cout<<ans; } int main(){ cin.tie(0); ios_base::sync_with_stdio(0); deal(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...