题面
题解
设(dp_{i,j})表示前(i)座塔派了总共(j)个人的最大收益,转移显然
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
const int N=105,M=20005;
int dp[N][M],a[N][N],sz,s,n,m,x,res,qwq;
int main(){
// freopen("testdata.in","r",stdin);
s=read(),n=read(),m=read();
fp(j,1,s)fp(i,1,n)a[i][j]=read();
fp(i,1,n)sort(a[i]+1,a[i]+1+s);
memset(dp,0xef,sizeof(dp));
qwq=dp[0][0],dp[0][0]=0;
fp(i,0,n-1){
fp(j,0,sz)if(dp[i][j]!=qwq){
cmax(dp[i+1][j],dp[i][j]);
fp(k,1,s){
x=j+a[i+1][k]*2+1;
if(x<=m)cmax(dp[i+1][x],dp[i][j]+k*(i+1));
else break;
}
}
sz+=a[i+1][s]*2+1,cmin(sz,m);
}
res=qwq;
fp(i,0,m)cmax(res,dp[n][i]);
printf("%d
",res);
return 0;
}