답안 #531216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531216 2022-02-28T05:09:08 Z azberjibiou Diversity (CEOI21_diversity) C++17
0 / 100
6 ms 1484 KB
#include <bits/stdc++.h>
#define gibon ios::sync_with_stdio(false); cin.tie(0);
#define fir first
#define sec second
#define pdd pair<double, double>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pmax pair<__int128, __int128>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
int dx[4]={0, 1, 0, -1}, dy[4]={1, 0, -1 , 0};
const int mxN=300003;
const int mxM=1010;
const int mxK=105;
const int MOD=1000000007;
const ll INF=1e18;
const ll P1=1000000007;
const ll P2=1000000009;
int N, Q;
int cnt[mxN];
ll ans;
int main()
{
    gibon
    cin >> N >> Q;
    for(int i=1;i<=N;i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }
    sort(cnt, cnt+mxN);
    ll ncnt=0;
    for(int i=0;i<mxN;i++)
    {
        if(cnt[i]==0)   continue;
        ans+=(ll)N*(N+1)/2-ncnt*(ncnt+1)/2-(ll)(N-ncnt-cnt[i])*(N-ncnt-cnt[i]+1)/2;
        ncnt+=cnt[i];
    }
    cout << ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1484 KB Output is correct
2 Correct 5 ms 1484 KB Output is correct
3 Correct 5 ms 1484 KB Output is correct
4 Incorrect 6 ms 1484 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1484 KB Output is correct
2 Correct 5 ms 1484 KB Output is correct
3 Correct 5 ms 1484 KB Output is correct
4 Incorrect 6 ms 1484 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1484 KB Output is correct
2 Correct 5 ms 1484 KB Output is correct
3 Correct 5 ms 1484 KB Output is correct
4 Incorrect 6 ms 1484 KB Output isn't correct
5 Halted 0 ms 0 KB -