#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef int64_t ll;
//~ #define int ll
const int M = 6e6 + 5;
const int N = 505;
const int K = 7;
ar<int, K> og[N];
vector<int> a[N], tot;
int n, p[N], sum[M], k;
void go(int i, int c, ar<int, K> a){
if(c == k){
sum[a[0]]++;
return;
}
for(int j=i;j<n;j++){
ar<int, K> b = a;
for(int k=1;k<K;k++){
if(og[p[j]][k] > b[k]){
b[0] += (og[p[j]][k] - b[k]);
b[k] = og[p[j]][k];
}
}
go(j + 1, c + 1, b);
}
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int c; cin>>n>>k>>c;
for(int i=0;i<n;i++){
for(int j=1;j<=k;j++) cin>>og[i][j], a[i].push_back(og[i][j]);
sort(a[i].rbegin(), a[i].rend());
a[i].push_back(i);
}
sort(a, a + n);
reverse(a, a + n);
if(k == 3) n = min(n, 70), assert(false);
if(k >= 4) n = min(n, 60);
for(int i=0;i<n;i++) p[i] = a[i].back();
go(0, 0, {});
for(int i=M-1;~i;i--){
//~ if(sum[i]) cout<<sum[i]<<" "<<i<<"\n";
if(c <= sum[i]){
cout<<i<<"\n";
return 0;
} c -= sum[i];
}
assert(false);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
7124 KB |
Output is correct |
2 |
Correct |
9 ms |
420 KB |
Output is correct |
3 |
Correct |
9 ms |
420 KB |
Output is correct |
4 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
4108 KB |
Output is correct |
2 |
Correct |
124 ms |
4800 KB |
Output is correct |
3 |
Correct |
129 ms |
5052 KB |
Output is correct |
4 |
Correct |
136 ms |
5320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1379 ms |
360 KB |
Output is correct |
2 |
Correct |
1306 ms |
460 KB |
Output is correct |
3 |
Incorrect |
1397 ms |
372 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
7124 KB |
Output is correct |
2 |
Correct |
9 ms |
420 KB |
Output is correct |
3 |
Correct |
9 ms |
420 KB |
Output is correct |
4 |
Correct |
7 ms |
340 KB |
Output is correct |
5 |
Correct |
124 ms |
4108 KB |
Output is correct |
6 |
Correct |
124 ms |
4800 KB |
Output is correct |
7 |
Correct |
129 ms |
5052 KB |
Output is correct |
8 |
Correct |
136 ms |
5320 KB |
Output is correct |
9 |
Correct |
1379 ms |
360 KB |
Output is correct |
10 |
Correct |
1306 ms |
460 KB |
Output is correct |
11 |
Incorrect |
1397 ms |
372 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |