Submission #1054019

#TimeUsernameProblemLanguageResultExecution timeMemory
1054019sleepntsheepDiversity (CEOI21_diversity)C++17
0 / 100
1 ms2396 KiB
#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) { for (; fr2[i]--; ++j) for (int xx = i; xx--;) a[o++] = 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 (stderr)

diversity.cpp: In function 'int main()':
diversity.cpp:22:19: warning: unused variable 'f' [-Wunused-variable]
   22 |   for (int c = 1, f = 0, i = n; i >= 1; --i) {
      |                   ^
diversity.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
diversity.cpp:11:37: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   for (int i = 1; i <= n; ++i) scanf("%d", a + i), ++fr[a[i]];
      |                                ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...