一道暴水的dp。。。。别问我为什么直接打开了G题,我只是对题目名称感兴趣而已。。。。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
int x=0; char ch=getchar();
for(;!isdigit(ch);ch=getchar());
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
return x;
}
ll f[37];
int n,c[5];
int main(){
n=read();
for(int i=1;i<=n;i++){
for(int j=0;j<5;j++) c[j]=read();
for(int k=30,u;k>=0;k--)
for(int j=0;j<5;j++){
u=k|(1<<j);
if(u>k) f[u]=max(f[u],f[k]+c[j]);
}
}
cout<<f[31]<<endl;
return 0;
}