제출 #1186606

#제출 시각아이디문제언어결과실행 시간메모리
1186606kl0989eOlympiads (BOI19_olympiads)C++20
0 / 100
2086 ms263176 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()

vi sco;

vi cur;
vector<vi> peop;

void dfs(int ind, int used) {
	if (used==cur.size()) {
		sco.pb(accumulate(all(cur),0));
		return;
	}
	if (ind==peop.size()) {
		return;
	}
	dfs(ind+1,used);
	vi t=cur;
	for (int i=0; i<cur.size(); i++) {
		cur[i]=max(cur[i],peop[ind][i]);
	}
	dfs(ind+1,used+1);
	cur=t;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	int n,k,c;
	cin >> n >> k >> c;
	cur.resize(k,0);
	peop.resize(n,vi(k,0));
	for (int i=0; i<n; i++) {
		for (int j=0; j<k; j++) {
			cin >> peop[i][j];
		}
	}
	dfs(0,0);
	sort(all(sco),[](int a, int b){return a>b;});
	cout << sco[c-1] << '\n';
	for (int i=0; i<sco.size(); i++) {
		cout << sco[i] << " \n"[i==sco.size()-1];
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...