Submission #164494

# Submission time Handle Problem Language Result Execution time Memory
164494 2019-11-21T06:01:52 Z balbit Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i<b; i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i = n-1; i>=0; i--)
#define SZ(x) (int)(x.size())
#define ALL(x) x.begin(),x.end()
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define pb push_back
#ifdef BALBIT
#define IOS()
#define bug(x) cerr<<__LINE__<<": "<<x<<endl
#else
#define IOS() ios::sync_with_stdio(0),cin.tie(0)
#define endl '\n'
#define bug(x)
#endif

const ll mod = 1e9+7;
const int maxn = 3e5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iinf = 0x3f3f3f3f;

struct pt{
	ll a, b;
};

signed main(){
	IOS();
	int n; cin>>n;
	vector<pt> v;
	REP(i,n){
		ll a, b; cin>>a>>b; v.pb({a,b});
	}
	sort(ALL(v), [](pt a, pt b){
		return a.a<b.a;
	});
	vector<ll>ps(n);
	ll mx = 0;
	ll re = 0;
	REP(i,n){
		ps[i+1] = ps[i] + v[i].b;
		MX(re, ps[i+1] - v[i].a + mx);
		MX(mx, v[i].a-ps[i]);
	}
	cout<<re<<endl;
	
}

# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -