Submission #1106081

#TimeUsernameProblemLanguageResultExecution timeMemory
1106081ngokhanhArt Exhibition (JOI18_art)C++17
50 / 100
1045 ms12872 KiB
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i=a;i<=b;i++) #define rep2(i,a,b,c) for (int i=a;i<=b;i+=c) #define rev(i,a,b) for (int i=a;i>=b;i--) #define rev2(i,a,b,c) for (int i=a;i>=b;i-=c) #define ii pair<ll,ll> #define bit(i,j) ((i>>j)&1) #define ull unsigned long long #define pb push_back #define pf push_front #define ll long long #define F first #define S second #define sz(a) (int)(a.size()) #define on(n) __builtin_popcountll(n) #define ld long double #define __log2(x) 63-__builtin_clzll(x) #define Mask(x) (1LL<<x) #define ALL(v) v.begin(),v.end() const int N=3e5+5; const int mod=998244353; int n; ii A[N]; ll p[N]; void solution(){ cin >> n; rep(i,1,n) cin >> A[i].F >> A[i].S; sort(A+1,A+1+n); rep(i,1,n) p[i]=p[i-1]+A[i].S; ll res=LLONG_MIN,Min=LLONG_MAX; rep(i,1,n){ Min=min(Min,p[i-1]-A[i].F); res=max(res,p[i]-A[i].F-Min); } cout << res; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int test=1; //cin >> test; while(test--) solution(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...