Submission #659724

# Submission time Handle Problem Language Result Execution time Memory
659724 2022-11-19T07:10:22 Z fatemetmhr Diversity (CEOI21_diversity) C++17
0 / 100
6 ms 1888 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb     push_back
#define fi     first
#define se     second
#define all(x) x.begin(), x.end()
 
const int maxn5 = 4e5 + 10;
 
int cnt[maxn5];
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
 
    int n, q; cin >> n >> q;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        cnt[a]++;
    }
    sort(cnt, cnt + maxn5);
    ll ans = 0;
    int a; cin >> a >> a;
    ll ind = 1;
    for(int i = 0; i < maxn5; i++) if(cnt[i] > 1){
        ans += ind * (n + 1 - ind);
        ind++; cnt[i]--;
        while(cnt[i]--){
            ans += (n + 1 - ind);
            ind++;
        }
    }
    for(int i = 0; i < maxn5; i++) if(cnt[i] == 1){
        ans += ind * (n + 1 - ind);
        ind++;
    }
    cout << ans << endl;
 
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1876 KB Output is correct
2 Correct 6 ms 1876 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Incorrect 6 ms 1880 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1876 KB Output is correct
2 Correct 6 ms 1876 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Incorrect 6 ms 1880 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1876 KB Output is correct
2 Correct 6 ms 1876 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Incorrect 6 ms 1880 KB Output isn't correct
5 Halted 0 ms 0 KB -