#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int n, k, c;
//multiset<ll, greater<ll>> ss;
vector<ll> sth;
vector<vector<ll>> v;
void bf(int cnt, int c, vector<ll> cur){
if(cnt == k){
ll s = 0;
for(ll x: cur) s+=x;
//ss.insert(s);
//if(ss.size() > c+5) ss.erase(prev(ss.end()));
sth.pb(s);
return;
}
if(c == n) return;
bf(cnt, c+1, cur);
for(int i = 0; i < k; i++) cur[i] = max(cur[i], v[c][i]);
bf(cnt+1, c+1, cur);
if(c == n) return;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> c;
for(int i = 0; i < n; i++){
vector<ll> sth(k);
for(ll &x: sth) cin >> x;
v.pb(sth);
}
bf(0, 0, vector<ll>(k, 0));
c--;
//cout << *next(ss.begin(), c) << "\n";
sort(sth.rbegin(), sth.rend());
cout << sth[c] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1484 KB |
Output is correct |
2 |
Correct |
19 ms |
1572 KB |
Output is correct |
3 |
Correct |
21 ms |
1484 KB |
Output is correct |
4 |
Correct |
16 ms |
1592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
697 ms |
33276 KB |
Output is correct |
2 |
Correct |
690 ms |
33200 KB |
Output is correct |
3 |
Correct |
781 ms |
33232 KB |
Output is correct |
4 |
Correct |
745 ms |
33248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2071 ms |
187724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1484 KB |
Output is correct |
2 |
Correct |
19 ms |
1572 KB |
Output is correct |
3 |
Correct |
21 ms |
1484 KB |
Output is correct |
4 |
Correct |
16 ms |
1592 KB |
Output is correct |
5 |
Correct |
697 ms |
33276 KB |
Output is correct |
6 |
Correct |
690 ms |
33200 KB |
Output is correct |
7 |
Correct |
781 ms |
33232 KB |
Output is correct |
8 |
Correct |
745 ms |
33248 KB |
Output is correct |
9 |
Execution timed out |
2071 ms |
187724 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |