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;
int n,m,k,a[7][550];
vector<int> srt,tmp;
void exh(int id,int curr,vector<int> &hv){
if (curr==k){
int ans=0;
for (int i=1;i<=k;i++){
int cmx=0;
for (int j:hv) cmx=max(cmx,a[i][j]);
ans+=cmx;
}
srt.push_back(ans);
return;
}
for (int i=id+1;i<=n;i++){
hv.push_back(i);
exh(i,curr+1,hv);
hv.pop_back();
}
}
int main(){
cin>>n>>k>>m;
for (int i=1;i<=n;i++) for (int j=1;j<=k;j++) cin>>a[j][i];
exh(0,0,tmp);
nth_element(srt.begin(),srt.begin()+m-1,srt.end(),greater<int>());
cout<<srt[m-1]<<"\n";
}
# | 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... |