Submission #972391

#TimeUsernameProblemLanguageResultExecution timeMemory
972391vjudge1Art Exhibition (JOI18_art)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
#define zet ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ll long long
#define pii pair<int, int>
using namespace std;
//const ll NN = 1e18+7;
//const int N = 1e5+15;
//pair<int, int> p[N];
//int a[N], sqr;
int main () {
    ll n; cin >> n;
	pii a[n];
	for(ll i = 0; i < n; i++)cin >> a[i].first >> a[i].second;
	sort(a + 1, a + n + 1);
	ll mx = a[0].second,x = a[0].second;
	for(ll i = 1; i < n; i++){
		x += a[i].second;
		x -= (a[i].first - a[i-1].first);
		if(x < a[i].second)x = a[i].second;
		mx = max(mx,x);
	}
	cout<<mx;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...