답안 #894833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894833 2023-12-29T05:32:37 Z vjudge1 Diversity (CEOI21_diversity) C++11
0 / 100
0 ms 500 KB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 3 * 1e5 + 10;
const ll mod = 1e9 + 7;

ll um(ll a, ll b){
	return ((1LL * a * b) % mod + mod) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
ll add(ll a, ll b){
	return (1LL * a + b) % mod;
}
ll binpow(ll x, ll step){
	ll res = 1LL;
	while(step){
		if(step & 1) res = um(res, x);
		x = um(x, x);
		step /= 2;
	}
	return res;
}
int arr[N];
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	ll n, q;
  	cin >> n >> q;
  	for(ll i = 1; i <= n; i++){
  		cin >> arr[i];
  	}
  	sort(arr + 1, arr + n + 1);
  	ll ans = 0, cnt= 0, cur = 0;
  	for(ll i = 1; i <= n; i++){
  		if(arr[i] != arr[i - 1]) cnt++;
  		cur += cnt;
  	}
  	for(ll i = 1; i <= n; i++){
  		//cout << cur << endl;
  		ans += cur;
  		cur--;
  		if(arr[i] != arr[i + 1]) cur -= (n - i);
  	}
  	cout << ans;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -