QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#773064#2200. Just Arrange the IconsvolfridCompile Error//C++20897b2024-11-23 00:29:292024-11-23 00:29:29

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 00:29:29]
  • 评测
  • [2024-11-23 00:29:29]
  • 提交

answer

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

void solve() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int& x : V) {
    cin >> x;
  }

  unordered_map<int, int> count;
  for (const int x : V) {
    count[x]++;
  }

  vector<int> frs;
  for (const auto& [key, val] : count) {
    frs.push_back(val);
  }
  sort(frs.begin(), frs.end());

  int answer = N;
  for (int s = 1; s <= frs.front() + 1; s++) {
    int solution = 0;
    bool is_bad = false;
    for (const int val : frs) {
      int fit = (val + s - 1) / s;
      if (val < fit * (s - 1)) {
        is_bad = true;
      }
      solution += fit;
    }
    if (!is_bad) {
      answer = min(answer, solution);
    }
  }
  cout << answer << "\n";
}

int main() {
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:24:3: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   24 |   sort(frs.begin(), frs.end());
      |   ^~~~
      |   short