显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int W,H;
int ti;
int location;
int v;
int score;
int f[110][1010]={ 0 };
int main()
{
freopen("freepizza.in","r",stdin);
freopen("freepizza.out","w",stdout);
scanf("%d%d",&W,&H);
int t=0;
while(cin>>ti>>location>>v>>score)
{
if(H%v==0)
{
f[H/v+ti][location]=score;
t=max(t,H/v+ti);
}
else
{
f[H/v+ti+1][location]=score;
t=max(t,H/v+ti+1);
}
}
for(int i=1;i<=t;++i)
{
for(int j=1;j<=W;++j)
{int x=f[i][j];
x=max(x,f[i][j]+f[i-1][j-2]);
x=max(x,f[i][j]+f[i-1][j-1]);
x=max(x,f[i][j]+f[i-1][j]);
x=max(x,f[i][j]+f[i-1][j+1]);
x=max(x,f[i][j]+f[i-1][j+2]);
f[i][j]=x;
}
}
int ans=0;
for(int i=1;i<=W;++i)
{
ans=max(ans,f[t][i]);
}
printf("%d\n",ans);
int y1=(W+1)/2;
for(int i=1;i<=t;++i)
{
int x=0;
int y;
for(int j=1;j<=W;++j)
{
if(x<f[i][j])
{
x=f[i][j];
y=j;
}
}
if(i!=1)
{
int st=y-y1;
st=max(st,-2);
st=min(st,2);
printf("%d\n",st);
y1=y;
}
}
return 0;
}