#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
using i64 = std::int64_t;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, Q;
std::cin >> N >> Q;
vector<int> A(N);
for (auto& x : A) {
std::cin >> x;
}
std::sort(A.begin(), A.end());
i64 ans = (i64)(N + 1) * N / 2;
for (int i = 0; i < N - 1; ++i) {
if (A[i] != A[i + 1]) {
ans += (i64)(i + 1) * (N - i - 1);
}
}
std::cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
292 KB |
Token "1" doesn't correspond to pattern "YES|NO" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
312 KB |
Token "1" doesn't correspond to pattern "YES|NO" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
292 KB |
Token "1" doesn't correspond to pattern "YES|NO" |
2 |
Halted |
0 ms |
0 KB |
- |