제출 #1341454

#제출 시각아이디문제언어결과실행 시간메모리
1341454zowiArt Exhibition (JOI18_art)C++20
100 / 100
137 ms8752 KiB
#include<bits/stdc++.h>
using namespace std;


int main()
{
	ios_base::sync_with_stdio(0);
	long long n,a,b;
	cin >> n;
	vector<pair<long long,long long>> tab;
	for(long long i = 0;i < n;++i)
	{
		cin >> a >> b;
		tab.push_back({a,b});
	}
	sort(tab.begin(),tab.end());
	long long best = 0;
	long long wyn = 0;
	for(long long i = 0;i < n;++i)
	{
		best = max(best,tab[i].first);
		best += tab[i].second;
		wyn = max(wyn,best-tab[i].first);
		//cout << wyn << endl;
	}
	cout << wyn;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...