Submission #972377

#TimeUsernameProblemLanguageResultExecution timeMemory
972377vjudge1Art Exhibition (JOI18_art)C++17
0 / 100
0 ms348 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 () {
    int n; cin >> n;
	pii a[n];
	for(int i=0;i<n;i++)cin >> a[i].first >> a[i].second;
	sort(a + 1, a + n + 1);
	int mx = a[0].second,x = a[0].second;
	for(int 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...