Submission #880240

#TimeUsernameProblemLanguageResultExecution timeMemory
880240niterArt Exhibition (JOI18_art)C++14
50 / 100
25 ms6424 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]; //P y[mxn]; int solve(int n){ // int real_ans; // string ans_mask; // cin >> real_ans >> ans_mask; ll ans = -(1e18); loop(i,1,n+1){ cin >> x[i].A >> x[i].B; // y[i] = x[i]; } x[0].A = x[0].B = 0; sort(x + 1, x + n + 1); ll mx = x[1].A, add = 0; for(int i = 1; i <= n; i++){ if(i != 1){ mx = max(mx, x[i].A - add); } add += x[i].B; // opa(i) opa(mx) opa(add) op(x[i].A) ans = max(ans, -x[i].A + mx + add); } // if(ans != real_ans){ // opa(ans) op(real_ans) // op(ans_mask) // loop(i,1,n+1){ // ops(y[i].A) spac ops(y[i].B) entr // } entr // exit(0); // } cout << ans; return 0; } int main(){ // freopen("res.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; solve(n); } /* 4 81 0110 2 10 42 42 48 45 7 12 3 50 010 2 5 24 50 1 13 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...