Submission #1054017

# Submission time Handle Problem Language Result Execution time Memory
1054017 2024-08-12T04:43:18 Z sleepntsheep Diversity (CEOI21_diversity) C
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#define N 300001
#define A 300001

int n, q, a[N], fr[N], fr2[N];
long long z, y;

int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), ++fr[a[i]];

  for (int i = 1; i <= 300000; ++i)
    ++fr2[fr[i]];

  for (int o = 1, j = 0, i = 1; i <= n; ++i) {
    while (fr2[i]--)
      a[o++] = j;
    ++j;
  }

  for (int c = 1, f = 0, i = n; i >= 1; --i) {
    z += (n - i + 1) * c - y;

    if (a[i] != a[i - 1]) {
        y += c;
      ++c;
    } else {
      y += c - 1;
    }
  }

  printf("%lld", z);

}

Compilation message

diversity.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.