# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054039 | 2024-08-12T05:12:44 Z | sleepntsheep | Diversity (CEOI21_diversity) | C++17 | 1 ms | 2480 KB |
#include <cstdio> #include <algorithm> #define N 300001 #define A 300001 int o, n, q, a[N], fr[N], fr2[N]; long long z, y; long long c2(int x) { return (x - 1ll) * x / 2ll; } 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 i = 1; i <= n; ++i) for (; fr2[i]--; ) a[++o] = i; for (int i = 1; i <= 10000; ++i) { int psum = a[1]; for (int j = 2; j <= o; psum += a[j++]) { int a_ = a[j - 1]; int b_ = a[j]; int x = psum - a_; int y = n - psum - b_; if (-c2(b_ + y + 1) -c2(a_ + x + 1) > -c2(b_ + x + 1) - c2(a_ + y + 1)) std::swap(a[j], a[j - 1]); } } int psum = 0; for (int i = 1; i <= o; psum += a[i++]) { z += c2(n + 1) - c2(psum + 1) - c2(n - psum - a[i] + 1); } printf("%lld", z); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2392 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Incorrect | 0 ms | 2480 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2392 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Incorrect | 0 ms | 2480 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2392 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Incorrect | 0 ms | 2480 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |