思路



#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 20;
int n, m, k;
ll a[maxn][maxn];
ll rsum[maxn], csum[maxn];
bool cmp(ll x, ll y){
    return x > y;
}
ll solve(int cal){
    int pos = 1; ll tmp = 0;
    vector<int> v, vec;
    while(cal){
        if(cal & 1){
            tmp += rsum[pos];
            v.push_back(pos);
        }
        pos++;
        cal /= 2;
    }
    if(v.size() > k) return 0;///行枚举无效
    for(int j = 1; j <= m; j++){
        ll gg = csum[j];
        for(auto &itm : v){
            gg -= a[itm][j];
        }
        vec.push_back(gg);
    }
    sort(vec.begin(), vec.end(), cmp);
    int num = k - v.size(); num = min(num, m);
    for(int i = 0; i < num; i++){
        tmp += vec[i];
    }
    return tmp;
}
int main(){
    scanf("%d%d%d", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            scanf("%lld", &a[i][j]);
            rsum[i] = rsum[i] + a[i][j];
            csum[j] = csum[j] + a[i][j];
        }
    }
    int ma = 1 << n;
    ll ans = 0;
    for(int i = 0; i < ma; i++){
        ans = max(ans, solve(i));
    }
    printf("%lld\n", ans);
    return 0;
}