Submission #964668

# Submission time Handle Problem Language Result Execution time Memory
964668 2024-04-17T09:56:20 Z UmairAhmadMirza Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=5e5+5;
int const mod=1e9+7;
pair<int,int> arr[N];
ll largest_subarray_sum(vector<int> v, int n){
	ll ans=0;
	ll cur=0;
	for(int i=0;i<n;i++){
		if(cur+v[i]>=0)
			cur+=v[i];
		else
			cur=0;
		ans=max(ans,cur);
	}
	return ans;
}
void solve(){
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i)
		cin>>arr[i].first>>arr[i].second;
	sort(arr,arr+n);
	vector<int> v;
	for(int i=0;i<n-1;i++){
		v.push_back(arr[i].second);
		v.push_back(arr[i].first-arr[i+1].first);
	}
	v.push_back(arr[n-1].second);
	cout<<largest_subarray_sum(v,2*n-1)<<endl;
}

int main(){
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -