Submission #298429

# Submission time Handle Problem Language Result Execution time Memory
298429 2020-09-12T20:36:33 Z peuch Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 640 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 600;
const int MAXK = 10;

int n, k, c;
multiset<int> ans;

struct competitor{
	vector<int> v;
	competitor(){}
	competitor(int size){
		v.clear();
		for(int i = 0; i < size; i++)
			v.push_back(0);
	}
	competitor(vector<int> _v){
		v = _v;
	}
	competitor operator + (competitor b){
		vector<int> ret;
		for(int i = 0; i < v.size(); i++)
			ret.push_back(max(v[i], b.v[i]));
		return competitor(ret);
	}
	int sum(){
		int ret = 0;
		for(int i = 0; i < v.size(); i++)
			ret += v[i];
		return ret;
	}
	void scan(int size){
		v.clear();
		int aux;
		for(int i = 0; i < size; i++){
			scanf("%d", &aux);
			v.push_back(aux);
		}
	}
} ppl[MAXN];

void bt(int cur, competitor team, int cnt);

int main(){
	scanf("%d %d %d", &n, &k, &c);
	for(int i = 0; i < n; i++) ppl[i].scan(k);
	bt(0, competitor(k), 0);
	printf("%d\n", *ans.begin());
}

void bt(int cur, competitor team, int cnt){
	if(cnt == k){
		ans.insert(team.sum());
		if(ans.size() > c) ans.erase(ans.begin());
		return;
	}
	if(cur >= n) return;
	bt(cur + 1, team, cnt);
	bt(cur + 1, team + ppl[cur], cnt + 1);
}

Compilation message

olympiads.cpp: In member function 'competitor competitor::operator+(competitor)':
olympiads.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
olympiads.cpp: In member function 'int competitor::sum()':
olympiads.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for(int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
olympiads.cpp: In function 'void bt(int, competitor, int)':
olympiads.cpp:55:17: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |   if(ans.size() > c) ans.erase(ans.begin());
      |      ~~~~~~~~~~~^~~
olympiads.cpp: In function 'int main()':
olympiads.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |  scanf("%d %d %d", &n, &k, &c);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp: In member function 'void competitor::scan(int)':
olympiads.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |    scanf("%d", &aux);
      |    ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 41 ms 512 KB Output is correct
2 Correct 41 ms 640 KB Output is correct
3 Correct 40 ms 512 KB Output is correct
4 Correct 48 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1983 ms 476 KB Output is correct
2 Correct 1978 ms 476 KB Output is correct
3 Correct 1912 ms 504 KB Output is correct
4 Correct 1986 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 41 ms 512 KB Output is correct
2 Correct 41 ms 640 KB Output is correct
3 Correct 40 ms 512 KB Output is correct
4 Correct 48 ms 632 KB Output is correct
5 Correct 1983 ms 476 KB Output is correct
6 Correct 1978 ms 476 KB Output is correct
7 Correct 1912 ms 504 KB Output is correct
8 Correct 1986 ms 504 KB Output is correct
9 Execution timed out 2033 ms 516 KB Time limit exceeded
10 Halted 0 ms 0 KB -