Submission #772677

#TimeUsernameProblemLanguageResultExecution timeMemory
772677NintsiChkhaidzeArt Exhibition (JOI18_art)C++17
100 / 100
177 ms13468 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define s second #define f first #define pll pair <ll,ll> #define pii pair <int,int> #define left h*2,l,(l + r)/2 #define right h*2+1,(l + r)/2 + 1,r using namespace std; const int N = 5e5 + 5; ll t[4*N],lz[4*N],p[N]; pll d[N]; signed main() { ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n; cin>>n; for (int i = 1; i <= n; i++){ cin>>d[i].f>>d[i].s; } sort(d + 1,d + n + 1); for (int i = 1; i <= n; i++){ p[i] = p[i - 1] + d[i].s; } ll ans = 0,mn = 1e18; for (int i = 0; i <= n; i++){ ans = max(ans, p[i] - d[i].f - mn); mn = min(mn, p[i] - d[i + 1].f); } 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...