Submission #298429

#TimeUsernameProblemLanguageResultExecution timeMemory
298429peuchOlympiads (BOI19_olympiads)C++17
44 / 100
2033 ms640 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...