제출 #1276732

#제출 시각아이디문제언어결과실행 시간메모리
1276732tm.khoa.tmArt Exhibition (JOI18_art)C++20
0 / 100
0 ms332 KiB
//I love ManchesterUnited #include<bits/stdc++.h> using namespace std; #define love ManchesterUnited #define int long long #define pb push_back #define FOR(i,a,b) for (int i=(a); i<=(b); i++) #define FORD(i,b,a) for (int i=(b); i>=(a); i--) #define REP(i, n) for(int i=0; i<(n); ++i) #define RED(i, n) for(int i=(n)-1; i>=0; --i) #define time() cerr << endl << "-------------Time:" << 1000.0 * clock() / CLOCKS_PER_SEC << "ms."; #define ALL(a) (a).begin(),(a).end() #define ii pair<int,int> #define iii pair<int,ii> #define fi first #define se second #define endl '\n' #define MASK(x) (1 << (x)) #define BIT(mask,i) ((mask >> i) & 1) typedef long long ll; template<class X, class Y> bool minimize(X &x, const Y &y) { if (x > y) { x = y; return true; } else return false; } template<class X, class Y> bool maximize(X &x, const Y &y) { if (x < y) { x = y; return true; } else return false; } template<class T> T Abs(const T &x) { return (x < 0 ? -x : x); } //___________________________________________________________________________________________________________________________________________________________ // CODE: const int N = 1e6 + 5; const int INF = 1e18; const int MOD = 1e9 + 7; int n; ii a[N]; int pre[N]; int32_t main() { // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; FOR(i,1,n) cin >> a[i].fi >> a[i].se; sort(a + 1 , a + n + 1); FOR(i,1,n) pre[i] = pre[i - 1] + a[i].se; int ans = 0, cnt= INF; FOR(i,1,n){ if (i >= 2) ans = max(ans, (pre[i] - a[i].fi) - cnt); cnt = min(cnt, pre[i - 1] - a[i].fi); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...