#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define FOR(i,a,b) for(int i = (a) , _b = (b); i <= _b; ++i)
#define sz(x) (int)(x).size()
#define BIT(mask , x) (((mask)>>(x))&(1))
#define MASK(x) ((LL)(1)<<(x))
template<class X,class Y>
bool maximize(X &x, Y y){
if (x<y) return x = y , true; else return false;
}
template<class X,class Y>
bool minimize(X &x, Y y){
if (x>y) return x = y , true; else return false;
}
const int N = (int)500;
const LL inf = (LL)1e18;
map<vector<int>,bool> mp;
int n , k , need_pos;
int a[N + 2][N + 2] = {};
LL C(int x,int y){
LL r1 = 1 , r2 = 1;
if (x>y) return 0;
FOR(i,y-x+1,y) r1 = r1 * i;
FOR(i,1,x) r2 = r2 * i;
return r1 / r2;
}
namespace subtask2{
bool check(){
return n <= 40;
}
int cur[8] = {};
int calc(){
int sum = 0;
for(int j = 0; j < k; ++j) {
int mx = 0;
for(int i = 0; i < k; ++i) {
maximize(mx , a[cur[i]][j]);
}
sum += mx;
}
return sum;
}
vector<int>v;
void recur(int id, int last = 0 ){
if (id == k) {
// cout<<1<<'\n';
// for(int i = 0; i < k; ++i) cout<<cur[i]<<' '; cout<<'\n';
v.push_back(calc());
return;
}
if (last + 1 > n) return;
for(int i = last + 1; i <= n; ++i){
cur[id] = i;
recur(id + 1 , i);
}
}
void main_code(){
recur(0,0);
sort(v.begin() , v.end() , greater<int>());
cout<<v[need_pos-1];
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0) ; cout.tie(0);
#define name "main"
if (fopen(name".inp","r")){
freopen(name".inp","r",stdin);
freopen(name".out","w",stdout);
}
cin >> n >> k >> need_pos;
FOR(i,1,n){
for(int j = 0; j < k; ++j) cin >> a[i][j];
}
// cout << need_pos << '\n';
return subtask2::main_code() , 0;
}
컴파일 시 표준 에러 (stderr) 메시지
olympiads.cpp: In function 'int main()':
olympiads.cpp:79:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
79 | freopen(name".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:80:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
80 | freopen(name".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | 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... |