답안 #921066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921066 2024-02-03T09:35:20 Z shoryu386 Olympiads (BOI19_olympiads) C++17
0 / 100
2000 ms 65852 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long


int scores[507][6];
int n, k, c;

vector<pair<int, int>> res;



map<pair<pair<int, int>, vector<int>>, int> store;

void recur(int x, int remain, vector<int> cur, int cnt){
	
	if (x == n){
		if (remain == 0){
			int lol = 0;
			for (int y = 0; y < k; y++) lol += cur[y];
			res.push_back({lol, cnt});
		}
		return;
	}
	
	store[{{x+1, remain}, cur}] += cnt;
	
	if (remain != 0){
		
		for (int y = 0; y < k; y++){
			cur[y] = max(cur[y], scores[x][y]);
		}
		store[{{x+1, remain-1}, cur}] += cnt;
	}
}

main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k >> c;
	
	for (int x = 0; x < n; x++){
		for (int y = 0; y < k; y++){
			cin >> scores[x][y];
		} 
	}
	
	vector<int> init;
	for (int x = 0; x < k; x++){
		init.push_back(LLONG_MIN/20);
	}
	
	store[{{0, k}, init}] = 1;
	
	while (!store.empty()){
		auto vals = *store.begin();
		
		recur(vals.first.first.first, vals.first.first.second, vals.first.second, vals.second);
		
		store.erase(store.begin());
	}
	
	sort(res.begin(), res.end(), greater<pair<int, int>>());
	c -= 2;
	
	int sum = 0;
	for (int x = res.size()-1; x > -1; x--){
		sum += res[x].second;
		if (sum >= c){
			cout << res[x].first;
			break;
		}
	}
}

Compilation message

olympiads.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2043 ms 7480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1280 ms 65852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 33020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2043 ms 7480 KB Time limit exceeded
2 Halted 0 ms 0 KB -