Submission #1034353

# Submission time Handle Problem Language Result Execution time Memory
1034353 2024-07-25T12:34:11 Z vjudge1 Diversity (CEOI21_diversity) C++17
64 / 100
97 ms 10692 KB
#include <bits/stdc++.h>
using namespace std;

string abc = "abcdefghijklmnopqrstuvwxyz";

#define int long long

int m = 3e5+7;

void solve(){
    int n, qq;
    cin >> n >> qq;
    // vector<int> v(n);
    vector<int> a(m, 0);
    int r;
    int sz = 0;
    for(int i = 0; i < n; i++){
        cin >> r;
        if(a[r]==0) sz++;
        a[r]++;
    }
    cin >> qq >> qq;
    vector<int> w, v(sz);
    for(int i = 0; i < m; i++){
        if(a[i] != 0){
            w.push_back(a[i]);
        }
    }
    sort(w.rbegin(), w.rend());
    int st = sz/2;
    v[st]=w[0];
    st--;
    int res = 2;
    for(int i = 1; i < sz; i++){
        v[st]=w[i];
        if(i%2 == 0) st-=res;
        else st+=res;
        res++;
    }

    int ans = 0;
    n = v.size();
    for(int i = 0; i < n; i++){
        ans+=v[i]*(v[i]+1)/2;
    }
    
    queue<int> q;
    int cur = 0;
    res = 0;
    for(int i = 1; i < n; i++){
        cur+=(i+1)*v[i];
        res+=v[i];
        q.push(v[i]);
    }
    for(int i = 0; i < n-1; i++){
        ans+=v[i]*cur;
        int a = q.front();
        cur-=res;
        cur-=a;
        res-=a;
        q.pop();
    }

    cout << ans << endl;
    

}


signed main(){
    int t = 1;

    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2676 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2668 KB Output is correct
7 Correct 1 ms 2784 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 3160 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 2 ms 2900 KB Output is correct
4 Correct 9 ms 2908 KB Output is correct
5 Correct 17 ms 3164 KB Output is correct
6 Correct 27 ms 3420 KB Output is correct
7 Correct 25 ms 3164 KB Output is correct
8 Correct 26 ms 3288 KB Output is correct
9 Correct 26 ms 3288 KB Output is correct
10 Correct 26 ms 3272 KB Output is correct
11 Correct 26 ms 3408 KB Output is correct
12 Correct 39 ms 3408 KB Output is correct
13 Correct 26 ms 3292 KB Output is correct
14 Correct 26 ms 3416 KB Output is correct
15 Correct 26 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 2 ms 2900 KB Output is correct
4 Correct 9 ms 2908 KB Output is correct
5 Correct 17 ms 3164 KB Output is correct
6 Correct 27 ms 3420 KB Output is correct
7 Correct 25 ms 3164 KB Output is correct
8 Correct 26 ms 3288 KB Output is correct
9 Correct 26 ms 3288 KB Output is correct
10 Correct 26 ms 3272 KB Output is correct
11 Correct 26 ms 3408 KB Output is correct
12 Correct 39 ms 3408 KB Output is correct
13 Correct 26 ms 3292 KB Output is correct
14 Correct 26 ms 3416 KB Output is correct
15 Correct 26 ms 3420 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 15 ms 3072 KB Output is correct
20 Correct 20 ms 3164 KB Output is correct
21 Correct 29 ms 3408 KB Output is correct
22 Correct 29 ms 3420 KB Output is correct
23 Correct 29 ms 3420 KB Output is correct
24 Correct 29 ms 3412 KB Output is correct
25 Correct 29 ms 3412 KB Output is correct
26 Correct 29 ms 3420 KB Output is correct
27 Correct 29 ms 3544 KB Output is correct
28 Correct 39 ms 3500 KB Output is correct
29 Correct 32 ms 3672 KB Output is correct
30 Correct 30 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 2 ms 2900 KB Output is correct
4 Correct 9 ms 2908 KB Output is correct
5 Correct 17 ms 3164 KB Output is correct
6 Correct 27 ms 3420 KB Output is correct
7 Correct 25 ms 3164 KB Output is correct
8 Correct 26 ms 3288 KB Output is correct
9 Correct 26 ms 3288 KB Output is correct
10 Correct 26 ms 3272 KB Output is correct
11 Correct 26 ms 3408 KB Output is correct
12 Correct 39 ms 3408 KB Output is correct
13 Correct 26 ms 3292 KB Output is correct
14 Correct 26 ms 3416 KB Output is correct
15 Correct 26 ms 3420 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 15 ms 3072 KB Output is correct
20 Correct 20 ms 3164 KB Output is correct
21 Correct 29 ms 3408 KB Output is correct
22 Correct 29 ms 3420 KB Output is correct
23 Correct 29 ms 3420 KB Output is correct
24 Correct 29 ms 3412 KB Output is correct
25 Correct 29 ms 3412 KB Output is correct
26 Correct 29 ms 3420 KB Output is correct
27 Correct 29 ms 3544 KB Output is correct
28 Correct 39 ms 3500 KB Output is correct
29 Correct 32 ms 3672 KB Output is correct
30 Correct 30 ms 3420 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 1 ms 2800 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 3 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 2 ms 2648 KB Output is correct
37 Correct 7 ms 2908 KB Output is correct
38 Correct 7 ms 2908 KB Output is correct
39 Correct 17 ms 3164 KB Output is correct
40 Correct 23 ms 3420 KB Output is correct
41 Correct 34 ms 3812 KB Output is correct
42 Correct 35 ms 3928 KB Output is correct
43 Correct 37 ms 3916 KB Output is correct
44 Correct 35 ms 3920 KB Output is correct
45 Correct 35 ms 3932 KB Output is correct
46 Correct 46 ms 3784 KB Output is correct
47 Correct 36 ms 3920 KB Output is correct
48 Correct 35 ms 4172 KB Output is correct
49 Correct 35 ms 3932 KB Output is correct
50 Correct 34 ms 3920 KB Output is correct
51 Correct 34 ms 3932 KB Output is correct
52 Correct 34 ms 3920 KB Output is correct
53 Correct 35 ms 3924 KB Output is correct
54 Correct 38 ms 3828 KB Output is correct
55 Correct 34 ms 3932 KB Output is correct
56 Correct 36 ms 3924 KB Output is correct
57 Correct 39 ms 4256 KB Output is correct
58 Correct 34 ms 3788 KB Output is correct
59 Correct 34 ms 3920 KB Output is correct
60 Correct 34 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2676 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2668 KB Output is correct
7 Correct 1 ms 2784 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 3160 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 2 ms 2900 KB Output is correct
14 Correct 9 ms 2908 KB Output is correct
15 Correct 17 ms 3164 KB Output is correct
16 Correct 27 ms 3420 KB Output is correct
17 Correct 25 ms 3164 KB Output is correct
18 Correct 26 ms 3288 KB Output is correct
19 Correct 26 ms 3288 KB Output is correct
20 Correct 26 ms 3272 KB Output is correct
21 Correct 26 ms 3408 KB Output is correct
22 Correct 39 ms 3408 KB Output is correct
23 Correct 26 ms 3292 KB Output is correct
24 Correct 26 ms 3416 KB Output is correct
25 Correct 26 ms 3420 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 15 ms 3072 KB Output is correct
30 Correct 20 ms 3164 KB Output is correct
31 Correct 29 ms 3408 KB Output is correct
32 Correct 29 ms 3420 KB Output is correct
33 Correct 29 ms 3420 KB Output is correct
34 Correct 29 ms 3412 KB Output is correct
35 Correct 29 ms 3412 KB Output is correct
36 Correct 29 ms 3420 KB Output is correct
37 Correct 29 ms 3544 KB Output is correct
38 Correct 39 ms 3500 KB Output is correct
39 Correct 32 ms 3672 KB Output is correct
40 Correct 30 ms 3420 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 1 ms 2800 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 3 ms 2652 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2648 KB Output is correct
47 Correct 7 ms 2908 KB Output is correct
48 Correct 7 ms 2908 KB Output is correct
49 Correct 17 ms 3164 KB Output is correct
50 Correct 23 ms 3420 KB Output is correct
51 Correct 34 ms 3812 KB Output is correct
52 Correct 35 ms 3928 KB Output is correct
53 Correct 37 ms 3916 KB Output is correct
54 Correct 35 ms 3920 KB Output is correct
55 Correct 35 ms 3932 KB Output is correct
56 Correct 46 ms 3784 KB Output is correct
57 Correct 36 ms 3920 KB Output is correct
58 Correct 35 ms 4172 KB Output is correct
59 Correct 35 ms 3932 KB Output is correct
60 Correct 34 ms 3920 KB Output is correct
61 Correct 34 ms 3932 KB Output is correct
62 Correct 34 ms 3920 KB Output is correct
63 Correct 35 ms 3924 KB Output is correct
64 Correct 38 ms 3828 KB Output is correct
65 Correct 34 ms 3932 KB Output is correct
66 Correct 36 ms 3924 KB Output is correct
67 Correct 39 ms 4256 KB Output is correct
68 Correct 34 ms 3788 KB Output is correct
69 Correct 34 ms 3920 KB Output is correct
70 Correct 34 ms 3924 KB Output is correct
71 Correct 8 ms 2908 KB Output is correct
72 Correct 13 ms 3016 KB Output is correct
73 Correct 8 ms 3160 KB Output is correct
74 Correct 10 ms 3012 KB Output is correct
75 Correct 9 ms 3012 KB Output is correct
76 Correct 14 ms 3288 KB Output is correct
77 Correct 18 ms 3248 KB Output is correct
78 Correct 14 ms 3164 KB Output is correct
79 Correct 14 ms 3164 KB Output is correct
80 Correct 15 ms 3260 KB Output is correct
81 Correct 29 ms 3920 KB Output is correct
82 Correct 40 ms 3912 KB Output is correct
83 Correct 38 ms 4012 KB Output is correct
84 Correct 28 ms 3928 KB Output is correct
85 Correct 28 ms 3932 KB Output is correct
86 Correct 37 ms 4300 KB Output is correct
87 Correct 32 ms 4300 KB Output is correct
88 Correct 60 ms 4300 KB Output is correct
89 Correct 31 ms 4308 KB Output is correct
90 Correct 32 ms 4308 KB Output is correct
91 Correct 58 ms 6856 KB Output is correct
92 Correct 51 ms 6700 KB Output is correct
93 Correct 49 ms 6856 KB Output is correct
94 Correct 85 ms 6852 KB Output is correct
95 Correct 49 ms 6720 KB Output is correct
96 Correct 72 ms 9412 KB Output is correct
97 Correct 85 ms 9348 KB Output is correct
98 Correct 62 ms 9412 KB Output is correct
99 Correct 65 ms 9408 KB Output is correct
100 Correct 86 ms 9412 KB Output is correct
101 Correct 83 ms 9272 KB Output is correct
102 Correct 97 ms 9412 KB Output is correct
103 Correct 59 ms 9412 KB Output is correct
104 Correct 71 ms 9392 KB Output is correct
105 Correct 67 ms 9408 KB Output is correct
106 Correct 73 ms 10432 KB Output is correct
107 Correct 70 ms 10672 KB Output is correct
108 Correct 57 ms 10436 KB Output is correct
109 Correct 91 ms 10432 KB Output is correct
110 Correct 58 ms 10692 KB Output is correct
111 Correct 81 ms 10432 KB Output is correct
112 Correct 95 ms 10436 KB Output is correct
113 Correct 74 ms 10564 KB Output is correct
114 Correct 75 ms 10436 KB Output is correct
115 Correct 95 ms 10672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2676 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2668 KB Output is correct
7 Correct 1 ms 2784 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 3160 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 2 ms 2900 KB Output is correct
14 Correct 9 ms 2908 KB Output is correct
15 Correct 17 ms 3164 KB Output is correct
16 Correct 27 ms 3420 KB Output is correct
17 Correct 25 ms 3164 KB Output is correct
18 Correct 26 ms 3288 KB Output is correct
19 Correct 26 ms 3288 KB Output is correct
20 Correct 26 ms 3272 KB Output is correct
21 Correct 26 ms 3408 KB Output is correct
22 Correct 39 ms 3408 KB Output is correct
23 Correct 26 ms 3292 KB Output is correct
24 Correct 26 ms 3416 KB Output is correct
25 Correct 26 ms 3420 KB Output is correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 15 ms 3072 KB Output is correct
30 Correct 20 ms 3164 KB Output is correct
31 Correct 29 ms 3408 KB Output is correct
32 Correct 29 ms 3420 KB Output is correct
33 Correct 29 ms 3420 KB Output is correct
34 Correct 29 ms 3412 KB Output is correct
35 Correct 29 ms 3412 KB Output is correct
36 Correct 29 ms 3420 KB Output is correct
37 Correct 29 ms 3544 KB Output is correct
38 Correct 39 ms 3500 KB Output is correct
39 Correct 32 ms 3672 KB Output is correct
40 Correct 30 ms 3420 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 1 ms 2800 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 3 ms 2652 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2648 KB Output is correct
47 Correct 7 ms 2908 KB Output is correct
48 Correct 7 ms 2908 KB Output is correct
49 Correct 17 ms 3164 KB Output is correct
50 Correct 23 ms 3420 KB Output is correct
51 Correct 34 ms 3812 KB Output is correct
52 Correct 35 ms 3928 KB Output is correct
53 Correct 37 ms 3916 KB Output is correct
54 Correct 35 ms 3920 KB Output is correct
55 Correct 35 ms 3932 KB Output is correct
56 Correct 46 ms 3784 KB Output is correct
57 Correct 36 ms 3920 KB Output is correct
58 Correct 35 ms 4172 KB Output is correct
59 Correct 35 ms 3932 KB Output is correct
60 Correct 34 ms 3920 KB Output is correct
61 Correct 34 ms 3932 KB Output is correct
62 Correct 34 ms 3920 KB Output is correct
63 Correct 35 ms 3924 KB Output is correct
64 Correct 38 ms 3828 KB Output is correct
65 Correct 34 ms 3932 KB Output is correct
66 Correct 36 ms 3924 KB Output is correct
67 Correct 39 ms 4256 KB Output is correct
68 Correct 34 ms 3788 KB Output is correct
69 Correct 34 ms 3920 KB Output is correct
70 Correct 34 ms 3924 KB Output is correct
71 Correct 8 ms 2908 KB Output is correct
72 Correct 13 ms 3016 KB Output is correct
73 Correct 8 ms 3160 KB Output is correct
74 Correct 10 ms 3012 KB Output is correct
75 Correct 9 ms 3012 KB Output is correct
76 Correct 14 ms 3288 KB Output is correct
77 Correct 18 ms 3248 KB Output is correct
78 Correct 14 ms 3164 KB Output is correct
79 Correct 14 ms 3164 KB Output is correct
80 Correct 15 ms 3260 KB Output is correct
81 Correct 29 ms 3920 KB Output is correct
82 Correct 40 ms 3912 KB Output is correct
83 Correct 38 ms 4012 KB Output is correct
84 Correct 28 ms 3928 KB Output is correct
85 Correct 28 ms 3932 KB Output is correct
86 Correct 37 ms 4300 KB Output is correct
87 Correct 32 ms 4300 KB Output is correct
88 Correct 60 ms 4300 KB Output is correct
89 Correct 31 ms 4308 KB Output is correct
90 Correct 32 ms 4308 KB Output is correct
91 Correct 58 ms 6856 KB Output is correct
92 Correct 51 ms 6700 KB Output is correct
93 Correct 49 ms 6856 KB Output is correct
94 Correct 85 ms 6852 KB Output is correct
95 Correct 49 ms 6720 KB Output is correct
96 Correct 72 ms 9412 KB Output is correct
97 Correct 85 ms 9348 KB Output is correct
98 Correct 62 ms 9412 KB Output is correct
99 Correct 65 ms 9408 KB Output is correct
100 Correct 86 ms 9412 KB Output is correct
101 Correct 83 ms 9272 KB Output is correct
102 Correct 97 ms 9412 KB Output is correct
103 Correct 59 ms 9412 KB Output is correct
104 Correct 71 ms 9392 KB Output is correct
105 Correct 67 ms 9408 KB Output is correct
106 Correct 73 ms 10432 KB Output is correct
107 Correct 70 ms 10672 KB Output is correct
108 Correct 57 ms 10436 KB Output is correct
109 Correct 91 ms 10432 KB Output is correct
110 Correct 58 ms 10692 KB Output is correct
111 Correct 81 ms 10432 KB Output is correct
112 Correct 95 ms 10436 KB Output is correct
113 Correct 74 ms 10564 KB Output is correct
114 Correct 75 ms 10436 KB Output is correct
115 Correct 95 ms 10672 KB Output is correct
116 Incorrect 2 ms 2904 KB Output isn't correct
117 Halted 0 ms 0 KB -