#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> A(n);
map<int, int> M;
for (int &a : A) cin >> a, M[a] = 0;
int k = 0;
for (auto &p : M) p.second = k++;
vector<LL> cnt(k);
for (int &a : A) a = M[a], ++cnt[a];
int L, R;
cin >> L >> R;
if (q > 1) return 0;
assert(q == 1 && L == 1 && R == n);
LL ans = 0;
sort(cnt.begin(), cnt.end());
for (LL c : cnt) ans += c * (c + 1) / 2 + c * (n - c);
LL B[2], gi = 1;
for (LL c : cnt) {
LL &l = B[gi ^ 1];
ans += l * (n - c - l), l += c;
// if (gi)
// ans += l * (n - c - l), l += c;
// else
// ans += r * (n - c - r), r += c;
gi ^= 1;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |