Submission #894834

# Submission time Handle Problem Language Result Execution time Memory
894834 2023-12-29T05:34:30 Z vjudge1 Diversity (CEOI21_diversity) C++11
0 / 100
0 ms 348 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);
  	if(q == 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;
  	} else while(true);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 -