#include<iostream>
using namespace std;
int xv[20], yv[20];
int l,h,n,xf,yf,lf,hf, aria;
void Citire() {
int i;
cout<<"numarul de pietre: "; cin>>n; cout<<n<<endl;
cout<<"coordonatele pietrelor: "<<endl<<endl;
for(i=1; i<=n; i++){
cout<<"piatra cu numarul "<<i<<" :"<<endl;
cout<<" xv: "; cin>>xv[i]; cout<<xv[i]<<endl;
cout<<" yv: "; cin>>yv[i]; cout<<yv[i]<<endl;
cout<<endl;
}
cout<<"lungimea gradinii: "; cin>>l; cout<<l<<endl;
cout<<"latimea gradinii: "; cin>>h; cout<<h<<endl;
cout<<endl;
}
void caut(int x,int y,int l,int h,int& xf,int& yf,int& lf,int& hf) {
int gasit=0,i=1;
while(i<=n && !gasit)
if(xv[i]>x && xv[i]<x+l && yv[i]>y && yv[i]<y+h) gasit=1;
else i++;
if(gasit) {
caut(x,y,xv[i]-x,h,xf,yf,lf,hf);
caut(xv[i],y,l+x-xv[i],h,xf,yf,lf,hf);
caut(x,y,l,yv[i]-y,xf,yf,lf,hf);
caut(x,yv[i],l,h+y-yv[i],xf,yf,lf,hf);
}
else
if(l*h>lf*hf) { xf=x; yf=y; lf=l; hf=h; }
}
int main()
{
Citire();
lf=0; hf=0;
caut(0,0,l,h,xf,yf,lf,hf);
aria=(lf-xf)*(hf-yf);
cout<<"bucata de arie maxima are coordonatele: "<<"xf="<<xf<<" yf="<<yf<<" lf="<<lf<<" hf="<<hf<<" si aria="<<aria<<endl<<endl;
return 0;
}