#include<bits/stdc++.h>
#define ll long long
#define vc vector
#define trav(a,x) for(auto& a : x)
#define all(v) v.begin(), v.end()
#define f(p,q,r) for(ll p=q;p<r;p++)
#define fr(p,q,r) for(ll p=q;p>=r;p--)
#define sz(x) (ll)(x).size()
#define el endl
#define pb push_back
#define pp pop_back
#define max_3(a,b,c) max(a,max(b,c))
#define min_3(a,b,c) min(a,min(b,c))
#define max_4(a,b,c,d) max(a,max(b,max(c,d)))
#define min_4(a,b,c,d) min(a,min(b,min(c,d)))
#define better_one ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
const int N=105;
int a[N][N],b[N][N],c[N][N];
void solve()
{
int n,m,k;
cin >> n >> m >> k;
string s;
f(i,1,n+1){
cin >> s;
f(j,1,m+1) cin >> a[i][j] >> b[i][j] >> c[i][j];
}
auto t=[&](int x,int y)
{
bool used[m+1]={0};
int ans=0,last=k;
while(last)
{
int mx=0,ix,ct;
f(i,1,m+1){
if(used[i]) continue;
if(b[y][i]-a[x][i]>mx)
{
ix=i;
mx=b[y][i]-a[x][i];
}
}
if(mx==0) break;
ct=min(last,c[x][ix]);
ans+=ct*mx;
used[ix]=1;
last-=ct;
}
return ans;
};
int ans=0;
f(i,1,n+1)
{
f(j,1,n+1) ans=max(ans,t(i,j));
}
cout<<ans;
}
int main ()
{
cout << el;
better_one;
int t=1;
// cin >> t;
while(t--)
{
solve();
}
return 0;
}
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |