#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500;
const int MAX_K = 6;
struct team {
int total;
int score[MAX_K];
void init() {
total = 0;
for ( int i = 0; i < MAX_K; i++ )
score[i] = 0;
}
bool operator < ( const team &t ) const {
return total < t.total;
}
team operator + ( const team &t ) const {
team ans;
ans.total = 0;
for ( int i = 0; i < MAX_K; i++ ) {
ans.score[i] = max( score[i], t.score[i] );
ans.total += ans.score[i];
}
return ans;
}
};
team students[MAX_N];
team maxScore[MAX_N + 1][MAX_K + 1];
int cnt;
void bckt( int c, int s, int p, int n, team crt ) {
// if ( (crt + maxScore[p + 1][c]).total < s )
// return;
if ( c == 0 ) {
if ( crt.total >=s )
cnt++;
return;
}
for ( int i = p + 1; i < n; i++ )
bckt( c - 1, s, i, n, crt + students[i] );
}
int main() {
int n, k, c;
cin >> n >> k >> c;
for ( int i = 0; i < n; i++ ) {
for ( int j = 0; j < k; j++ ) {
cin >> students[i].score[j];
students[i].total += students[i].score[j];
}
}
for ( int i = n - 1; i >= 0; i-- ) {
for ( int c = 1; c <= k; c++ )
maxScore[i][c] = max( maxScore[i + 1][c], maxScore[i + 1][c - 1] + students[i] );
}
int st = 0, dr = maxScore[0][k].total + 1;
while ( dr - st > 1 ) {
int mij = (st + dr) / 2;
cnt = 0;
team crt;
crt.init();
bckt( k, mij, -1, n, crt );
if ( cnt < c )
dr = mij;
else
st = mij;
}
cout << st;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
348 KB |
Output is correct |
2 |
Correct |
15 ms |
348 KB |
Output is correct |
3 |
Correct |
12 ms |
348 KB |
Output is correct |
4 |
Correct |
29 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1067 ms |
440 KB |
Output is correct |
2 |
Correct |
1070 ms |
348 KB |
Output is correct |
3 |
Correct |
1111 ms |
436 KB |
Output is correct |
4 |
Correct |
1118 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2028 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
348 KB |
Output is correct |
2 |
Correct |
15 ms |
348 KB |
Output is correct |
3 |
Correct |
12 ms |
348 KB |
Output is correct |
4 |
Correct |
29 ms |
544 KB |
Output is correct |
5 |
Correct |
1067 ms |
440 KB |
Output is correct |
6 |
Correct |
1070 ms |
348 KB |
Output is correct |
7 |
Correct |
1111 ms |
436 KB |
Output is correct |
8 |
Correct |
1118 ms |
436 KB |
Output is correct |
9 |
Execution timed out |
2028 ms |
344 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |