제출 #704217

#제출 시각아이디문제언어결과실행 시간메모리
704217alanlArt Exhibition (JOI18_art)C++14
100 / 100
171 ms20684 KiB
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define rep(X, a,b) for(int X=a;X<b;++X)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define NL "\n"
using namespace std;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){
	for(const auto &a:p)
		os << a << " ";
	os << "\n";
	return os;
}

typedef pair<ll, pll> ppp;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<pll> v(n);
	rep(i,0,n) cin>>v[i].F>>v[i].S;
	sort(ALL(v));
	ll ans=0, tot=0, mx=0;
	rep(i,0,n){
		mx=max(mx, v[i].F-tot);
		tot+=v[i].S;
		ans=max(ans, tot-v[i].F+mx);
	}
	cout<<ans<<NL;
	// ll n, m;
	// cin>>n>>m;
	// vector<string> grid(n);
	// vector<vector<ll>> dp(n, vector<ll>(0,m));
	// rep(i,0,n) cin>>grid[i];
	// ll ans=0;
	// rep(i,0,n){
	// 	rep(j,0,m){
	// 		if(grid[i][j]!='R') continue;
	// 		//right
	// 		if(m-j>=2){
	// 			if(grid[i][j+1]=='G' && grid[i][j+2]=='W'){
	// 			}
	// 		}
	// 		if(n-i>=2){
	// 			;
	// 		}
	// 		if(j-m>=2){
	// 			;
	// 		}
	// 		if(i-n>=2){
	// 			;
	// 		}
	// 	}
	// }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...