Submission #880197

#TimeUsernameProblemLanguageResultExecution timeMemory
880197niterArt Exhibition (JOI18_art)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define loop(i,a,b) for(int i = (a); i < (b); i ++) #define pb push_back #define ins insert #define pii pair<int,int> #define ff first #define ss second #define op(x) cerr << #x << " = " << x << endl; #define opa(x) cerr << #x << " = " << x << ", "; #define ops(x) cerr << x; #define entr cerr << endl; #define spac cerr << ' '; #define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl; #define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl; #define BAE(x) x.begin(), x.end() #define unilize(x) x.resize(unique(BAE(x)) - x.begin()) #define unisort(x) sort(BAE(x)); unilize(x); using namespace std; typedef long long ll; struct P{ ll A, B; bool operator<(P x){ return (A == x.A) ? (B < x.B) : (A < x.A); } }; const int mxn = (int)(1e5) + 10; P x[mxn]; int main(){ // freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; ll ans = -(1e18); loop(i,1,n+1){ cin >> x[i].A >> x[i].B; } x[0].A = x[0].B = 0; sort(x + 1, x + n + 1); ll sum_B = 0; for(int i = 1, j = 1; i <= n; i++){ sum_B += x[i].B; while(j < n && j < i){ if(sum_B - x[j].B + x[j+1].A >= sum_B + x[j].A){ sum_B -= x[j].B; j++; } else break; } // opa(i) op(j) op(sum_B) ans = max(ans, sum_B - x[i].A + x[j].A); } 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...