Submission #875737

#TimeUsernameProblemLanguageResultExecution timeMemory
875737nasir_bashirovArt Exhibition (JOI18_art)C++11
0 / 100
1 ms348 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define db long double #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vii vector<pii> #define vll vector<pll> #define endl '\n' #define all(x) x.begin(), x.end() #define fastio\ ios_base::sync_with_stdio(0);\ cin.tie(0);\ cout.tie(0)\ #define int long long const int sz = 5e5 + 5; int n; pii a[sz]; signed main(){ cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i].first >> a[i].second; } sort(a + 1, a + n + 1); int res = -1e18, p = 1, s = 0; for(int i = 1; i <= n; i++){ s += a[i].second; while(p < i and a[p + 1].first - a[p].first > a[p].second){ s -= a[p].second, p++; } res = max(res, s - (a[i].first - a[p].first)); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...