#include <bits/stdc++.h>
using namespace std;
#define int long long
int scores[507][6];
int n, k, c;
vector<int> res;
void recur(int x, int remain, vector<int> cur){
if (x == n){
if (remain == 0){
int lol = 0;
for (int y = 0; y < k; y++) lol += cur[y];
res.push_back(lol);
}
return;
}
recur(x+1, remain, cur);
if (remain != 0){
for (int y = 0; y < k; y++){
cur[y] = max(cur[y], scores[x][y]);
}
recur(x+1, remain-1, cur);
}
}
main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k >> c;
for (int x = 0; x < n; x++){
for (int y = 0; y < k; y++){
cin >> scores[x][y];
}
}
vector<int> init;
for (int x = 0; x < k; x++){
init.push_back(LLONG_MIN/20);
}
recur(0, k, init);
sort(res.begin(), res.end(), greater<int>());
cout << res[c-1];
}
Compilation message
olympiads.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
35 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
426 ms |
1588 KB |
Output is correct |
2 |
Correct |
421 ms |
1488 KB |
Output is correct |
3 |
Correct |
441 ms |
1684 KB |
Output is correct |
4 |
Correct |
431 ms |
1556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
765 ms |
34732 KB |
Output is correct |
2 |
Correct |
782 ms |
34948 KB |
Output is correct |
3 |
Correct |
797 ms |
34032 KB |
Output is correct |
4 |
Correct |
768 ms |
33452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2027 ms |
133116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
426 ms |
1588 KB |
Output is correct |
2 |
Correct |
421 ms |
1488 KB |
Output is correct |
3 |
Correct |
441 ms |
1684 KB |
Output is correct |
4 |
Correct |
431 ms |
1556 KB |
Output is correct |
5 |
Correct |
765 ms |
34732 KB |
Output is correct |
6 |
Correct |
782 ms |
34948 KB |
Output is correct |
7 |
Correct |
797 ms |
34032 KB |
Output is correct |
8 |
Correct |
768 ms |
33452 KB |
Output is correct |
9 |
Execution timed out |
2027 ms |
133116 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |