Submission #148195

# Submission time Handle Problem Language Result Execution time Memory
148195 2019-08-31T17:10:38 Z claudy Olympiads (BOI19_olympiads) C++14
44 / 100
584 ms 33612 KB
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

/*
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
Tree<int>tr;
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int mx[10];
vector<int>vec;
int n,k,c,a[505][505];
vector<int>ans;

inline void rec(int idxk, int idx){
	if(idxk == k){
		//~ for(auto it : vec) cout << it << ' ';
		//~ cout << '\n';
		int x = 0;
		for(int i = 0;i < k;i++) mx[i] = 0;
		for(auto it : vec){
			for(int i = 0;i < k;i++) mx[i] = max(mx[i],a[it][i]);
		}
		for(int i = 0;i < k;i++) x += mx[i];
		ans.pb(x);
		return ;
	}
	for(int i = idx + 1;i <= n;i++){
		vec.pb(i);
		rec(idxk + 1,i); 
		vec.pop_back();
	}
}

void solve1(){
	rec(0,0);
	sort(ans.rbegin(),ans.rend());
	//~ cout << sz(ans) << '\n';
	cout << ans[c - 1] << '\n';
	return ;
}

int hm[10];

int f(int n,int k){
	int ans = 1;
	for(int i = n;i > n - k;i--) ans *= i;
	for(int i = 1;i <= k;i++) ans /= i;
	return ans;
}

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n >> k >> c;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < k;j++) {
			cin >> a[i][j];
			hm[j] = max(hm[j],a[i][j]);
		}
	}
	//~ if(n <= 40 || k <= 2){
		//~ solve1();
	//~ }
	if(0){}
	else{
		if(f(n,k) <= f(40,6)) solve1();
		else{
		int x = 0;
		for(int i = 0;i < k;i++) x += hm[i];
		rc(x);
	}
	}
	return 0;
}









Compilation message

olympiads.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3572 KB Output is correct
2 Correct 13 ms 3444 KB Output is correct
3 Correct 12 ms 3568 KB Output is correct
4 Correct 8 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 555 ms 33504 KB Output is correct
2 Correct 544 ms 33540 KB Output is correct
3 Correct 584 ms 33480 KB Output is correct
4 Correct 555 ms 33612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 4 ms 2268 KB Output is correct
3 Incorrect 4 ms 2296 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3572 KB Output is correct
2 Correct 13 ms 3444 KB Output is correct
3 Correct 12 ms 3568 KB Output is correct
4 Correct 8 ms 3576 KB Output is correct
5 Correct 555 ms 33504 KB Output is correct
6 Correct 544 ms 33540 KB Output is correct
7 Correct 584 ms 33480 KB Output is correct
8 Correct 555 ms 33612 KB Output is correct
9 Correct 4 ms 2296 KB Output is correct
10 Correct 4 ms 2268 KB Output is correct
11 Incorrect 4 ms 2296 KB Output isn't correct
12 Halted 0 ms 0 KB -