Doubt in understanding the question i think according to question answer should be 6

GRAND TEMPLE
A religious king wants to build the largest temple in his kingdom . To build the largest temple he needs to find the area of the largest suitable land . Given co-ordinates which denotes rivers flowing through the point horizontally as well as vertically , find the largest area possible to make the grand temple.

Input Format:
An integer n denoting number of co-ordinates followed by n co-ordinates

Constraints:
1 <= N <= 10^5 | Ai | <= 10^9

Output Format
Largest possible area to build the grand temple

Sample Input
3
1 1
2 4
5 2
Sample Output
2

Hey, output 2 is correct for the sample input. As 2 is the area between (2,2), (2,4), (5,2), (5,4) i.e. For the largest possible region found the area will be calculated from the edge next to the left edge, the edge above the bottom edge, the topmost edge and the rightmost edge i.e for the region (2,2), (2,4), (5,2), (5,4) the actual area will be considered from (3,2), (3,4), (5,2), (5,4) respectively.
To understand this more clearly draw the diagram on a paper.

Hope this helps you :slight_smile:

Anyone could solve this problem

Hey, first try to code this problem atleast once… if you got stuck somewhere do let us know, we will help you out.

Hi! To find out what I can do, say @discobot display help.

@discobot
This is solution of this problem
#include

#include

#define ll long long int

using namespace std ;

int main()

{

ll n ;

cin>>n ;

n++;

ll x[n],y[n];

x[0] = 0 ,y[0]  =0 ;

for(int i =1 ;i<n ;i++)

{

     cin>>x[i]>>y[i];

}

sort(x,x+n);

sort(y,y+n);

ll maxx = 0 ,maxy = 0 ;

for(int i =0 ;i<n ;i++)

{

maxx= max(maxx,x[i]-x[i-1]-1);

    maxy= max(maxy,y[i]-y[i-1]-1);

}

cout<<maxx*maxy<<endl;

return 0 ;

}

Hi! To find out what I can do, say @discobot display help.