Submission #1088176

# Submission time Handle Problem Language Result Execution time Memory
1088176 2024-09-14T04:50:11 Z MahmytM Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
void afterdot(int n){
	cout<<setprecision(n)<<fixed;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
	ll n;
	cin>>n;
	pair<ll,ll> a[n+2],b[n+2];
	for(int i=1;i<=n;i++){
		cin>>a[i].ff>>a[i].ss;
		b[i].ff=a[i].ss,b[i].ss=a[i].ff;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	ll ans=0,sum=0;
	for(int i=1;i<=n;i++){
		sum+=a[i].ss;
		ans=max(ans,sum-(a[i].ff-a[1].ff));
	}
	sum=0;
	ll mn=1e18,mx=0;
	for(int i=1;i<=n;i++){
		sum+=b[i].ff;
		mx=max(mx,b[i].ss);
		mn=min(mn,b[i].ss);
		ans=max(ans,sum-(mx-mn));
	}
	cout<<ans<<endl;
}
# 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 -