이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
// }
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |