답안 #854523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854523 2023-09-27T20:19:31 Z tvladm2009 Olympiads (BOI19_olympiads) C++17
0 / 100
11 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N = 500 + 7;
const int K = 10;
const int MX = 100 + 7;
int score[N][K];
int f[K][MX];
int n, k, c;
vector<int> team, v;

void rec(int cnt = 1) {
  if (cnt == k + 1) {
    vector<int> total(k + 1, 0);
    for (auto &i : team) {
      for (int j = 1; j <= k; j++) {
        total[j] = max(total[j], score[i][j]);
      }
    }
    int now = 0;
    for (int j = 1; j <= k; j++) {
      now += total[j];
    }
    v.push_back(now);
    return;
  }
  int start = (team.empty() ? 1 : team.back() + 1);
  for (int i = start; i <= n; i++) {
    team.push_back(i);
    rec(cnt + 1);
    team.pop_back();
  }
}

signed main() {
#ifdef ONPC
  freopen ("input.txt", "r", stdin);
#else
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif // ONPC

  cin >> n >> k >> c;
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      cin >> score[i][j];
      mx = max(mx, score[i][j]);
      f[j][score[i][j]]++;
    }
  }

  if (mx <= 10) {
    vector<int> config_final;
    function<void(int)> solve = [&](int lvl) {
      if (lvl == k + 1) {
        ll ways = 1;
        for (int i = 1; i <= k; i++) {
          ways *= f[i][config_final[i - 1]];
        }
        c -= ways;
        if (c <= 0) {
          int sol = 0;
          for (auto &i : config_final) {
            sol += i;
          }
          cout << sol << "\n";
          exit(0);
        }
        return;
      }
      for (int i = mx; i >= 1; i--) {
        config_final.push_back(i);
        solve(lvl + 1);
        config_final.pop_back();
      }
    };
    solve(1);
    return 0;
  }


  rec();
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  cout << v[c - 1] << "\n";
  return 0;
}
/**

dp[i][mxa][mxb] = ?

**/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 11 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -