#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int SCORE = 100;
int n, k, c;
int a[501][7];
//int dp[501][7][6*SCORE + 5];
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k >> c;
for(int i = 1;i <= n; i++){
for(int j = 1;j <= k; j++){
cin >> a[i][j];
}
}
vector<int> sc;
if(k ==2){
for(int i = 1;i <= n; i++){
for(int j = i + 1;j <= n; j++){
sc.push_back(max(a[i][1], a[j][1]) + max(a[j][2], a[i][2]));
}
}
}else if(k == 1){
for(int i = 1;i <= n; i++){
sc.push_back(a[i][1]);
}
}else if(k == 6){
for(int i = 1;i <= n; i++){
for(int j = i + 1;j <= n; j++){
for(int ii = j + 1; ii <= n;ii++){
for(int jj = ii+1; jj <= n; jj++){
for(int iii = jj + 1; iii <= n; iii++){
for(int jjj = iii + 1; jjj <= n; jjj++){
int sum = 0;
for(int kk = 1;kk <= k; kk++){
sum+= max({a[i][kk], a[j][kk], a[ii][kk], a[jj][kk], a[iii][kk], a[jjj][kk]});
}
sc.push_back(sum);
}
}
}
}
}
}
}else if(k == 5){
for(int i = 1;i <= n; i++){
for(int j = i + 1;j <= n; j++){
for(int ii = j + 1; ii <= n;ii++){
for(int jj = ii+1; jj <= n; jj++){
for(int iii = jj + 1; iii <= n; iii++){
int sum = 0;
for(int kk = 1;kk <= k; kk++){
sum+= max({a[i][kk], a[j][kk], a[ii][kk], a[jj][kk], a[iii][kk]});
}
sc.push_back(sum);
}
}
}
}
}
}else if(k == 4){
for(int i = 1;i <= n; i++){
for(int j = i + 1;j <= n; j++){
for(int ii = j + 1; ii <= n;ii++){
for(int jj = ii+1; jj <= n; jj++){
int sum = 0;
for(int kk = 1;kk <= k; kk++){
sum+= max({a[i][kk], a[j][kk], a[ii][kk], a[jj][kk]});
}
sc.push_back(sum);
}
}
}
}
}else{
for(int i = 1;i <= n; i++){
for(int j = i + 1;j <= n; j++){
for(int ii = j + 1; ii <= n;ii++){
int sum = 0;
for(int kk = 1;kk <= k; kk++){
sum+= max({a[i][kk], a[j][kk], a[ii][kk] });
}
sc.push_back(sum);
}
}
}
}
sort(all(sc));
reverse(all(sc));
// for(auto x : sc) cout << x << ' ';
// cout << '\n';
cout << sc[c-1];
return 0;
}
Compilation message
olympiads.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1496 KB |
Output is correct |
2 |
Correct |
8 ms |
1756 KB |
Output is correct |
3 |
Correct |
5 ms |
1496 KB |
Output is correct |
4 |
Correct |
3 ms |
1500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
336 ms |
33484 KB |
Output is correct |
2 |
Correct |
324 ms |
34224 KB |
Output is correct |
3 |
Correct |
349 ms |
33708 KB |
Output is correct |
4 |
Correct |
335 ms |
33568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
488 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1496 KB |
Output is correct |
2 |
Correct |
8 ms |
1756 KB |
Output is correct |
3 |
Correct |
5 ms |
1496 KB |
Output is correct |
4 |
Correct |
3 ms |
1500 KB |
Output is correct |
5 |
Correct |
336 ms |
33484 KB |
Output is correct |
6 |
Correct |
324 ms |
34224 KB |
Output is correct |
7 |
Correct |
349 ms |
33708 KB |
Output is correct |
8 |
Correct |
335 ms |
33568 KB |
Output is correct |
9 |
Runtime error |
488 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |