百度之星12初赛(尼玛)

#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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值