Submission #1209520

#TimeUsernameProblemLanguageResultExecution timeMemory
1209520Theo830Olympiads (BOI19_olympiads)C++20
13 / 100
7 ms1472 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
int main(void){
    ll n,k,c;
    cin>>n>>k>>c;
    ll arr[n][k];
    f(i,0,n){
        f(j,0,k){
            cin>>arr[i][j];
        }
    }
    if(k == 1){
        vector<ll>ex;
        f(i,0,n){
            ex.pb(arr[i][0]);
        }
        sort(all(ex));
        reverse(all(ex));
        cout<<ex[c-1]<<"\n";
    }
    else if(k == 2){
        vector<ll>ex;
        f(i,0,n){
            f(j,i+1,n){
                ll sum = 0;
                f(u,0,2){
                    sum += max(arr[i][u],arr[j][u]);
                }
                ex.pb(sum);
            }
        }
        sort(all(ex));
        reverse(all(ex));
        cout<<ex[c-1]<<"\n";
    }
    else if(k == 3){
        vector<ll>ex;
        f(i,0,n){
            f(j,i+1,n){
                f(k,j+1,n){
                    ll sum = 0;
                    f(u,0,3){
                        sum += max({arr[i][u],arr[j][u],arr[k][u]});
                    }
                    ex.pb(sum);
                }
            }
        }
        sort(all(ex));
        reverse(all(ex));
        cout<<ex[c-1]<<"\n";
    }
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...