| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 127234 | nhimnam120 | Art Exhibition (JOI18_art) | C++14 | 2 ms | 376 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
set<long long> inp;
map<long long, long long> val;
vector<pair<long long, long long> > pro;
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n;
	cin >> n;
	for(int i=1;i<=n;i++){
		long long a,b;
		cin >> a >> b;
		val[a]+=b;
		inp.insert(a);
	}
	for(auto x: inp){
		pro.push_back({x,val[x]});
	}
	long long mdx=INT_MIN;
	long long max_end_here=0;
	long long MAX=INT_MIN,MIN=INT_MAX;
	long long sum=0;
	for(int i=0;i<pro.size();i++){
		if(MAX<pro[i].fi){
			MAX=pro[i].fi;
		}
		if(MIN>pro[i].fi){
			MIN=pro[i].fi;
		}
		sum+=pro[i].se;
		max_end_here=sum - (MAX-MIN);
		if(max_end_here>mdx){
			mdx=max_end_here;
		}
		if(max_end_here<0){
			max_end_here=0;
			MAX=INT_MIN;
			MIN=INT_MAX;
			sum=0;
		}
	}
	cout << mdx;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
