# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
857921 | 2023-10-07T07:21:29 Z | danikoynov | Diversity (CEOI21_diversity) | C++14 | 1 ms | 2496 KB |
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); } const int maxn = 3e5 + 10; int n, q, a[maxn], cnt[maxn]; void solve() { cin >> n >> q; for (int i = 1; i <= n; i ++) cin >> a[i]; int l, r; cin >> l >> r; for (int i = 1; i <= n; i ++) cnt[a[i]] ++; vector < ll > groups; for (int i = 1; i <= n; i ++) if (cnt[i] > 0) groups.push_back((ll)(cnt[i])); sort(groups.begin(), groups.end()); ll ans = 0; for (ll i = 0; i < groups.size(); i ++) for (ll j = i + 1; j < groups.size(); j ++) { ans = ans + groups[i] * groups[j] * (j - i + 1); } for (int i = 0; i < groups.size(); i ++) { ll cur = groups[i]; ans = ans + cur * (cur + 1) / 2; } cout << ans << endl; } int main() { solve(); return 0; } /** 4 1 1 1 1 1 1 2 2 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2496 KB | Output is correct |
4 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2496 KB | Output is correct |
4 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2496 KB | Output is correct |
4 | Incorrect | 1 ms | 2392 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |