Submission

Status:
[PPPPP][PPP][PPPPPPP]

Score: 100

User: admin

Problemset: 05.Two Towers

Language: cpp

Time: 0.039 second

Submitted On: 2025-03-31 01:54:53

#include <bits/stdc++.h>
#define ll long long

#define pii pair<ll , ll>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N;
	cin >>N;
	vector<pii> v;
	for (int i=0; i<N;i++) {
		ll x,y;
		cin >> x>>y;
		v.push_back({x, y});
	}
	
	sort(v.begin(), v.end());
	
	ll L =0;
	ll R =N-1;
	ll mx = -1;
	while (L<R) {
		mx = max(abs(v[R].first-v[L].first)*min(v[L].second, v[R].second), mx);
		if (v[L].second < v[R].second) {
			L++;
		} else {
			R--;
		}
	}
	cout << mx;
	return 0;
}