code
#include<bits/stdc++.h>
using namespace std;
int a[10010];
bool b[10010];
int main()
{
int i,j,n,ma,s,l;
scanf("%d",&n);
for(j=1;j<=n;j++)
{
s=0;
memset(b,false,sizeof(b));
b[0]=true;
while(1)
{
scanf("%d",&l);
if(l==-1)break;
for(i=s;i>=0;i--)
if(b[i])b[i+l]=true;
s+=l;
}
ma=max(ma,s);
for(i=1;i<=s;i++)if(b[i])a[i]++;
}
for(i=ma;i>0;i--)if(a[i]==n)break;
printf("%d",i);
return 0;
}
100
70
60
50
40
30