제출 #55253

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

using namespace std;
#define maxn 500010
#define ll long long

map<ll, ll> mp;
int N;
ll a[maxn], b[maxn];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		mp[0-a[i]] += b[i];
	}
	ll ans = 0LL;
	ll cbest = 0;
	ll lastval = 0-mp.begin()->first;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		ll cspot = 0-it->first;
		ll cnum = it->second;
		// cout << cspot << ": " << cnum << endl;
		cbest = max(cnum, cbest - (lastval - cspot) + cnum);
		ans = max(ans, cbest);
		lastval = cspot;
	}
	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...