Submission #525503

#TimeUsernameProblemLanguageResultExecution timeMemory
525503Yazan_AlattarOlympiads (BOI19_olympiads)C++14
100 / 100
1581 ms1920 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back //#define endl "\n" #define all(x) x.begin(), x.end() const int M = 507; const ll inf = 1e9; const ll mod = 998244353; const double pi = acos(-1); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int n, k, c, a[M][M]; bool valid (vector <int> v, int person) { for(auto i : v) if(person == i) return 0; return 1; } int val (vector <int> v) { int ret = 0; for(int i = 1; i <= (int)v.size(); ++i){ int mx = 0; for(auto j : v) mx = max(mx, a[j][i]); ret += mx; } return ret; } int main() { scanf("%d%d%d", &n, &k, &c); for(int i = 1; i <= n; ++i) for(int j = 1; j <= k; ++j) scanf("%d", &a[i][j]); set < pair < int, vector <int> > > s; s.insert({0, {}}); for(int turn = 1; turn <= k; ++turn){ set < pair < int, vector <int> > > to; for(auto i : s){ for(int j = 1; j <= n; ++j) if(valid(i.S, j)) { vector <int> tmp = i.S; tmp.pb(j); sort(all(tmp)); to.insert({val(tmp), tmp}); } while((int)to.size() > c + 200) to.erase(to.begin()); } s = to; } vector <int> ans; for(auto i : s) ans.pb(i.F); printf("%d\n", ans[s.size() - c]); return 0; }

Compilation message (stderr)

olympiads.cpp: In function 'int main()':
olympiads.cpp:34:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |      scanf("%d%d%d", &n, &k, &c);
      |      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:35:67: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |      for(int i = 1; i <= n; ++i) for(int j = 1; j <= k; ++j) scanf("%d", &a[i][j]);
      |                                                              ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...