Hello sir, I have tried to code the solution myself after understanding the logic but though it gave the current result on the sample input test when I tried to submit the given code on spoj it’s giving a runtime error can you please guide me so that I could make changes so that it could work.
code :-
#include
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
int arr[100000];
int brr[100000];
for(int i=0;i<c;i++)
{
cin>>arr[i];
cin>>brr[i];
}
sort(arr,arr+c);
sort(brr,brr+c);
vector<int>v1;
vector<int>v2;
int ans1=0;
int ans2=0;
for(int i=0;i<c;i++)
{
int k=arr[i]-ans1-1;
v1.push_back(k);
ans1=arr[i];
}
v1[c]=a-arr[2];
for(int i=0;i<c;i++)
{
int l=brr[i]-ans2-1;
v2.push_back(l);
ans2=brr[i];
}
v2[c]=b-brr[2];
// sorting both the vecttors to get the largest element
sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());
cout<<v1.back()*v2.back();
}
//asquare();
return 0;
}