#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 45
#define K 6
int n, c, k, a[N][K], cc[50000000], tp;
int main() {
scanf("%d%d%d", &n, &k, &c);
for (int i = 0; i < n; ++i)
for (int j = 0; j < k; ++j)
scanf("%d", &a[i][j]);
if (k == 6) {
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
for (int l = j + 1; l < n; ++l)
for (int o = l + 1; o < n; ++o)
for (int p = o + 1; p < n; ++p)
for (int u = p + 1; u < n; ++u)
{
int x = 0;
for (int i1 = 0; i1 < k; ++i1) {
int yy = max(max(max(a[p][i1], a[o][i1]), max(a[u][i1], a[i][i1])), max(a[j][i1], a[l][i1]));
x -= yy;
}
cc[tp++] = x;
}
} else if (k == 4) {
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
for (int l = j + 1; l < n; ++l)
for (int o = l + 1; o < n; ++o) {
int x = 0;
for (int i1 = 0; i1 < k; ++i1) {
int yy = max(max(a[o][i1], a[i][i1]), max(a[j][i1], a[l][i1]));
x -= yy;
}
cc[tp++] = x;
}
} else if (k == 5) {
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
for (int l = j + 1; l < n; ++l)
for (int o = l + 1; o < n; ++o)
for (int p = o + 1; p < n; ++p)
{
int x = 0;
for (int i1 = 0; i1 < k; ++i1) {
int yy = max(max(max(a[p][i1], a[o][i1]), a[i][i1]), max(a[j][i1], a[l][i1]));
x -= yy;
}
cc[tp++] = x;
}
} else if (k == 3) {
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
for (int l = j + 1; l < n; ++l) {
int x = 0;
for (int i1 = 0; i1 < k; ++i1) {
int yy = max(a[i][i1], max(a[j][i1], a[l][i1]));
x -= yy;
}
cc[tp++] = x;
}
} else if (k == 2) {
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j) {
cc[tp++] = -max(a[i][0], a[j][0]) + -max(a[j][1], a[i][1]);
}
} else {
for (int i = 0; i < n; ++i)
cc[tp++] = -a[i][0];
}
nth_element(cc, cc + c - 1, cc + tp);
printf("%d\n", -cc[c - 1]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
olympiads.cpp: In function 'int main()':
olympiads.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d%d%d", &n, &k, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:15:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d", &a[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~
# | 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... |