/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Runtime Error foo: foo.cc:9: void solve(int): Assertion `n % k == 0' failed. 2ms 580.0 KiB
#3 Runtime Error foo: foo.cc:9: void solve(int): Assertion `n % k == 0' failed. 2ms 532.0 KiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void solve(int cs) {
  int n, k;
  cin >> n >> k;
  assert(n % k == 0);
  map<int,int> cnt;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x] += 1;
  }
  int res = 0;
  int g = n / k;
  for (auto it : cnt) {
    res += it.second % g;
  }
  cout << res / 2 << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1062 Roy and Array
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 18:32:15
Judged At
2024-11-11 03:22:16
Judged By
Score
5
Total Time
2ms
Peak Memory
580.0 KiB