# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531855 | 2022-03-01T17:31:45 Z | hoanghq2004 | Diversity (CEOI21_diversity) | C++14 | 1 ms | 320 KB |
#include <bits/stdc++.h> #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 3e5 + 10; int n, q; int a[N]; long long ans = 0; int main() { ios :: sync_with_stdio(0); cin.tie(0); cin >> n >> q; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); vector <int> s; for (int i = 1; i <= n; ) { int j = i; while (j <= n && a[i] == a[j]) ++j; int L = i - 1, R = n - j + 1; ans += 1LL * (j - i) * L + 1LL * (j - i) * R; ans += 1LL * L * R; ans += 1LL * (j - i) * (j - i + 1) / 2; i = j; } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 320 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 320 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 320 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |