Zhall_Dreamy @ 2024-11-30 17:54:20
90分,#2 WA,标准输出7430,我的程序输出7400(就差30啊啊啊)
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int val=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
val*=10,val+=ch-'0',ch=getchar();
return val*f;
}
inline void write(int val)
{
if(val<0) putchar('-'),val=-val;
if(val>9) write(val/10);
putchar(val%10+'0');
}
int m,n,x,y,s,f[214514],size,w[32005][4],v[32005][4];
signed main()
{
m=read(),n=read();
for(int i=1;i<=n;i++)
{
x=read(),y=read(),s=read();
if(s==0)
{
w[i][0]=x;
w[i][1]+=x,w[i][2]+=x,w[i][3]+=x;
v[i][0]=x*y;
v[i][1]+=x*y,v[i][2]+=x*y,v[i][3]+=x*y;
}
else if(w[s][1]==0&&v[s][1]==0)
w[s][1]+=x,v[s][1]+=x*y,w[s][3]+=x,v[s][3]+=x*y;
else w[s][2]+=x,v[s][2]+=x*y,w[s][3]+=x,v[s][3]+=x*y;
}
for(int i=1;i<=n;i++)
for(int j=m;j>=0;j--)
for(int k=0;k<4;k++)
if(j>=w[i][k])
f[j]=max(f[j],f[j-w[i][k]]+v[i][k]);
write(f[m]);
return 0;
}
by Genshin_Venti @ 2024-12-02 18:44:03
%%%