# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303015 | bigg | Olympiads (BOI19_olympiads) | C++14 | 2040 ms | 34660 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 510;
vector<int> allteams;
bool marc[MAXN];
int scores[MAXN][MAXN]; //score do i-esimo cara no j-esimo esporte;
int maxnesse[MAXN];
int n, k;
void backtrack(int numteam, int id){
if(numteam > k) return;
if(numteam == k){
int soma = 0;
for(int i = 1; i <= k; i++){
maxnesse[i] = 0;
}
for(int i = 1; i <= n; i++){
if(!marc[i]) continue;
for(int j = 1; j <= k; j++){
if(scores[i][j] > maxnesse[j]){
soma += scores[i][j] - maxnesse[j];
maxnesse[j] = scores[i][j];
}
}
}
allteams.push_back(soma);
return;
}
if(id == n + 1) return;
marc[id] = 1;
backtrack(numteam + 1, id + 1);
marc[id] = 0;
backtrack(numteam, id + 1);
}
int c;
int main(){
scanf("%d %d %d", &n, &k, &c);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= k; j++){
scanf("%d", &scores[i][j]);
}
}
backtrack(0, 1);
sort(allteams.begin(), allteams.end());
printf("%d\n", allteams[n-c] );
}
Compilation message (stderr)
# | 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... |