답안 #964835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964835 2024-04-17T15:57:39 Z MinaRagy06 Diversity (CEOI21_diversity) C++17
0 / 100
1 ms 2904 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int N = 300'005;
int a[N], frq[N];
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		frq[a[i]]++;
	}
	vector<int> v;
	for (int i = 0; i < N; i++) {
		if (frq[i]) {
			v.push_back(frq[i]);
		}
	}
	n = v.size();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += v[i] * (v[i] + 1) / 2;
		for (int j = i + 1; j < n; j++) {
			ans += 1ll * v[i] * v[j] * (j - i + 1);
		}
	}
	cout << ans << '\n';
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 1 ms 2904 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 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 2392 KB Output is correct
3 Incorrect 1 ms 2904 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 1 ms 2904 KB Output isn't correct
4 Halted 0 ms 0 KB -