제출 #55255

#제출 시각아이디문제언어결과실행 시간메모리
55255shoemakerjoArt Exhibition (JOI18_art)C++14
100 / 100
500 ms148040 KiB
#include <bits/stdc++.h>

using namespace std;
#define maxn 500010
#define ll long long
#define pll pair<ll, ll>

vector<pll> stuff;
int N;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	ll a, b;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		stuff.push_back(pll(a, b));
	}
	sort(stuff.begin(), stuff.end());
	ll ans = 0LL;
	ll cbest = 0;
	ll lastval = stuff[0].first;
	ll cspot, cnum;
	for (int i = 0; i < N; i++) {
		cspot = stuff[i].first;
		cnum = stuff[i].second;
		cbest = max(cnum, cnum + cbest - (cspot - lastval));
		lastval = cspot;
		ans = max(ans, cbest);
	}
	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...