#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
int mat[maxn][10];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n, k, c;
cin >> n >> k >> c;
for(int i=1; i<=n; i++){
for(int j=1; j<=k; j++){
cin >> mat[i][j];
}
}
vector<int> pos;
if(k == 1){
for(int a=1; a<=n; a++) pos.push_back(mat[a][1]);
}
else if(k == 2){
for(int a=1; a<=n; a++){
for(int b=a+1; b<=n; b++){
int ans = 0;
for(int i=1; i<=k; i++) ans += max(mat[a][i], mat[b][i]);
pos.push_back(ans);
}
}
}
else if(k == 3){
for(int a=1; a<=n; a++){
for(int b=a+1; b<=n; b++){
for(int c=b+1; c<=n; c++){
int ans = 0;
for(int i=1; i<=k; i++) ans += max({mat[a][i], mat[b][i], mat[c][i]});
pos.push_back(ans);
}
}
}
}
else if(k == 4){
for(int a=1; a<=n; a++){
for(int b=a+1; b<=n; b++){
for(int c=b+1; c<=n; c++){
for(int d=c+1; d<=n; d++){
int ans = 0;
for(int i=1; i<=k; i++) ans += max({mat[a][i], mat[b][i], mat[c][i], mat[d][i]});
pos.push_back(ans);
}
}
}
}
}
else if(k == 5){
for(int a=1; a<=n; a++){
for(int b=a+1; b<=n; b++){
for(int c=b+1; c<=n; c++){
for(int d=c+1; d<=n; d++){
for(int e=d+1; e<=n; e++){
int ans = 0;
for(int i=1; i<=k; i++) ans += max({mat[a][i], mat[b][i], mat[c][i], mat[d][i], mat[e][i]});
pos.push_back(ans);
}
}
}
}
}
}
else{
for(int a=1; a<=n; a++){
for(int b=a+1; b<=n; b++){
for(int c=b+1; c<=n; c++){
for(int d=c+1; d<=n; d++){
for(int e=d+1; e<=n; e++){
for(int f=e+1; f<=n; f++){
int ans = 0;
for(int i=1; i<=k; i++) ans += max({mat[a][i], mat[b][i], mat[c][i], mat[d][i], mat[e][i], mat[f][i]});
pos.push_back(ans);
}
}
}
}
}
}
}
sort(pos.begin(), pos.end());
reverse(pos.begin(), pos.end());
cout << pos[c-1] << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
1024 KB |
Output is correct |
2 |
Correct |
12 ms |
1024 KB |
Output is correct |
3 |
Correct |
10 ms |
1024 KB |
Output is correct |
4 |
Correct |
7 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
541 ms |
16852 KB |
Output is correct |
2 |
Correct |
509 ms |
16856 KB |
Output is correct |
3 |
Correct |
588 ms |
16852 KB |
Output is correct |
4 |
Correct |
524 ms |
16852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1571 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
1024 KB |
Output is correct |
2 |
Correct |
12 ms |
1024 KB |
Output is correct |
3 |
Correct |
10 ms |
1024 KB |
Output is correct |
4 |
Correct |
7 ms |
1024 KB |
Output is correct |
5 |
Correct |
541 ms |
16852 KB |
Output is correct |
6 |
Correct |
509 ms |
16856 KB |
Output is correct |
7 |
Correct |
588 ms |
16852 KB |
Output is correct |
8 |
Correct |
524 ms |
16852 KB |
Output is correct |
9 |
Runtime error |
1571 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Halted |
0 ms |
0 KB |
- |