#include<iostream>
#include<stack>
#include<list>
using namespace std;
typedef struct
{
int f;
int g;
}Scheme;
int Solve(int X,int Y,int A,int B)
{
return A*X+B*Y;
}
int main()
{
int n=0;
cin>>n;
int *X=new int[n+1];
int *Y=new int[n+1];
int i;
for(i=1;i<=n;++i)
{
cin>>X[i];
cin>>Y[i];
}
int k[2]={0,0},A[2]={0,0},B[2]={0,0} ;
int gSum=0;
do
for(i=0;i<2;++i)
{
cin>>k[i]>>A[i]>>B[i];
gSum+=k[i];
}
while(gSum<n);
int hSum=0;
int max=hSum;
Scheme *sch=new Scheme[2*n+1];
for(i=1;i<=(1+n)*2;++i)
{
sch[i].f=(i+1)/2;
sch[i].g=(i+1)%2;
}
int *path=new int[n+1];
stack<int> sk;
sk.push(1);
sk.push(2);
while(!sk.empty())
{
int s=sch[sk.top()].g;
path[sch[sk.top()].f]=s;
if(sch[sk.top()].f==n)
{
for(int j=1;j<=n;++j)
{
int happy=Solve(X[j],Y[j],A[path[j]],B[path[j]]);
hSum+=happy;
}
if(hSum>max)
max=hSum;
hSum=0;
}
int nextFrd=sch[sk.top()].f+1;
sk.pop();
if(nextFrd<=n)
{
sk.push( 2*nextFrd-1);
sk.push(2*nextFrd);
}
}
cout<<max<<endl;
return 0;
}
#include<stack>
#include<list>
using namespace std;
typedef struct
{
int f;
int g;
}Scheme;
int Solve(int X,int Y,int A,int B)
{
return A*X+B*Y;
}
int main()
{
int n=0;
cin>>n;
int *X=new int[n+1];
int *Y=new int[n+1];
int i;
for(i=1;i<=n;++i)
{
cin>>X[i];
cin>>Y[i];
}
int k[2]={0,0},A[2]={0,0},B[2]={0,0} ;
int gSum=0;
do
for(i=0;i<2;++i)
{
cin>>k[i]>>A[i]>>B[i];
gSum+=k[i];
}
while(gSum<n);
int hSum=0;
int max=hSum;
Scheme *sch=new Scheme[2*n+1];
for(i=1;i<=(1+n)*2;++i)
{
sch[i].f=(i+1)/2;
sch[i].g=(i+1)%2;
}
int *path=new int[n+1];
stack<int> sk;
sk.push(1);
sk.push(2);
while(!sk.empty())
{
int s=sch[sk.top()].g;
path[sch[sk.top()].f]=s;
if(sch[sk.top()].f==n)
{
for(int j=1;j<=n;++j)
{
int happy=Solve(X[j],Y[j],A[path[j]],B[path[j]]);
hSum+=happy;
}
if(hSum>max)
max=hSum;
hSum=0;
}
int nextFrd=sch[sk.top()].f+1;
sk.pop();
if(nextFrd<=n)
{
sk.push( 2*nextFrd-1);
sk.push(2*nextFrd);
}
}
cout<<max<<endl;
return 0;
}