Grand temple greedy algorithm

im getting wrong answer
#include <bits/stdc++.h>
#define ll unsigned long long int
#define pb emplace_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector
#define all(v) (v).begin(),(v).end()
using namespace std;

int main(){
ll w=15,h=8,n;
cin>>n;
vector hv;
vector wv;
for(ll i=0;i<n;i++)
{ll a,b;
cin>>a>>b;
wv.push_back(a);
hv.push_back(b);
}

sort(all(wv));
sort(all(hv));
vector<ll> wd;vector<ll> hd;
for(ll i=0;i<wv.size()-1;i++)
	{wd.push_back(wv[i+1]-wv[i]-1);
	hd.push_back(hv[i+1]-hv[i]-1);
	}
cout<<(*max_element(all(wd)))*(*max_element(all(hd)))<<endl;

return 0;
}

Hello,

For test case:
3
1 1
6 6
6 5
Your output:
18446744073709551613 (Junk Value)
Expected Output:
12 (4*3)

This is coming because of 6-6-1.
Add following modification to judge your code:

for(ll i=0;i<wv.size()-1;i++)
{cout<<wv[i]<<" “<<wv[i+1]<<” "<<wv[i+1]-wv[i]-1<<endl;
wd.push_back(wv[i+1]-wv[i]-1);
hd.push_back(hv[i+1]-hv[i]-1);
}
cout<<endl;

I have explained enough, now it’s your task to resolve this error and others(if any) you encounter.

Hope, this would help.
If you face problem even after trying hard, feel free to ask.
Give a like if you are satisfied.

Mark it as resolved, if your problem is solved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.