답안 #146826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146826 2019-08-26T10:23:26 Z Vlatko Olympiads (BOI19_olympiads) C++14
44 / 100
2000 ms 131912 KB
#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 500;
const int maxk = 6;

int n, k, c;
int p[maxn][maxk];
vector<int> scores;

// vector<pair<int, vector<int>>> teams;
vector<int> team;

int getscore(vector<int> &team) {
    int score = 0;
    for (int i = 0; i < k; ++i) {
        int res = 0;
        for (int j = 0; j < k; ++j) {
            res = max(res, p[team[j]][i]);
        }
        score += res;
    }
    return score;
}

void gen(int i, int num) {
    if (num == k) {
        // teams.emplace_back(getscore(team), team);
        scores.push_back(getscore(team));
    } else if (i == n) {
        return;
    } else {
        gen(i+1, num);
        team.push_back(i);
        gen(i+1, num+1);
        team.pop_back();
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k >> c;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < k; ++j) {
            cin >> p[i][j];
        }
    }
    gen(0, 0);
    
    sort(scores.begin(), scores.end(), greater<int>());
    cout << scores[c-1] << endl;

    // for (int i = 0; i < (int)scores.size(); ++i) {
    //     debug(i, scores[i]);
    // }

    // sort(teams.rbegin(), teams.rend());
    // team.resize(k);
    // int i = 0;
    // for (auto &p : teams) {
    //     int score = p.first;
    //     int diff = 0;
    //     for (int i = 0; i < k; ++i) {
    //         if (team[i] != p.second[i]) {
    //             ++diff;
    //         }
    //         team[i] = p.second[i];
    //     }
    //     debug(i, score, team, diff);
    //     ++i;
    // }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1016 KB Output is correct
2 Correct 13 ms 1016 KB Output is correct
3 Correct 11 ms 1016 KB Output is correct
4 Correct 8 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 568 ms 16940 KB Output is correct
2 Correct 562 ms 16956 KB Output is correct
3 Correct 584 ms 16852 KB Output is correct
4 Correct 558 ms 16852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2033 ms 131912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1016 KB Output is correct
2 Correct 13 ms 1016 KB Output is correct
3 Correct 11 ms 1016 KB Output is correct
4 Correct 8 ms 1016 KB Output is correct
5 Correct 568 ms 16940 KB Output is correct
6 Correct 562 ms 16956 KB Output is correct
7 Correct 584 ms 16852 KB Output is correct
8 Correct 558 ms 16852 KB Output is correct
9 Execution timed out 2033 ms 131912 KB Time limit exceeded
10 Halted 0 ms 0 KB -