제출 #1342958

#제출 시각아이디문제언어결과실행 시간메모리
1342958Jakub_WozniakOlympiads (BOI19_olympiads)C++20
44 / 100
1813 ms327680 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 509;
const int maxk = 6;
int N , K;
vector <ll> V;
vector <ll> a;
int A[maxn][maxk];

void rek(int i , int k , vector <int> a)
{
    if(k == K)
    {
        ll S = 0;
        for(auto p : a)S += p;
        V.push_back(S);
        return ;
    }
    if((N-i) < (K-k))return ; // za malo zeby zdazyc wepchac k ludzi
    rek(i+1,k,a);
    for(int j = 0; j < K ; j++)
    {
        a[j] = max(a[j] , A[i][j]);
    }
    rek(i+1,k+1,a);
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int C;
    cin >> N >> K >> C;
    for(int i =0 ; i < N ; i++)for(int j =0 ; j < K ; j++)cin >> A[i][j];

    rek(0,0,vector<int>(K,0));

    sort(V.begin() , V.end());

    cout << V[V.size() - C] << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...