Submission #549537

# Submission time Handle Problem Language Result Execution time Memory
549537 2022-04-16T03:06:15 Z minhcool Diversity (CEOI21_diversity) C++17
64 / 100
68 ms 8268 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 4e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, q, a[N];

ii cnt[N];

void process(){
    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        cnt[a[i]].fi++;
    }
    for(int i = 1; i <= 300000; i++) cnt[i].se = i;
    sort(cnt + 1, cnt + 300000 + 1, greater<ii>());
    deque<int> dq;
    int tol = 0, tol2 = 0, toll = 0;
    for(int i = 299999; i >= 1; i -= 2){
        tol2 += (cnt[i].fi * (cnt[i].fi + 1)) / 2;
        tol2 += (cnt[i].fi * tol);
        tol += cnt[i].fi;
        toll += cnt[i].fi;
        tol += toll;
    }
    for(int i = 2; i <= 300000; i += 2){
        tol2 += (cnt[i].fi * (cnt[i].fi + 1)) / 2;
        tol2 += (cnt[i].fi * tol);
        tol += cnt[i].fi;
        toll += cnt[i].fi;
        tol += toll;
    }
    /*
    for(int i = 1; i <= 300000; i++){
        if(i & 1) for(int j = 1; j <= cnt[i].fi; j++) dq.push_front(cnt[i].se);
        else for(int j = 1; j <= cnt[i].fi; j++) dq.push_back(cnt[i].se);
    }
    int cnt = 0, tol = 0, lst = -1, tol2 = 0;
    //cout << dq.size() << "\n";
    while(dq.size()){
        int u = dq.front();
        //cout << u << "\n";
        dq.pop_front();
        cnt++;
        if(lst != u) tol += cnt;
        else tol++;
        tol2 += tol;
        lst = u;
    }*/
    cout << tol2 << "\n";
}

signed main(){
    ios_base::sync_with_stdio(0);
    process();
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4948 KB Output is correct
2 Correct 36 ms 4948 KB Output is correct
3 Correct 37 ms 4948 KB Output is correct
4 Correct 36 ms 4936 KB Output is correct
5 Correct 35 ms 4936 KB Output is correct
6 Correct 34 ms 4936 KB Output is correct
7 Correct 38 ms 4948 KB Output is correct
8 Correct 40 ms 4948 KB Output is correct
9 Correct 35 ms 4948 KB Output is correct
10 Correct 34 ms 4936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4948 KB Output is correct
2 Correct 40 ms 5020 KB Output is correct
3 Correct 41 ms 5116 KB Output is correct
4 Correct 43 ms 5996 KB Output is correct
5 Correct 45 ms 6868 KB Output is correct
6 Correct 53 ms 8024 KB Output is correct
7 Correct 55 ms 7984 KB Output is correct
8 Correct 58 ms 7924 KB Output is correct
9 Correct 58 ms 7876 KB Output is correct
10 Correct 52 ms 7900 KB Output is correct
11 Correct 51 ms 8008 KB Output is correct
12 Correct 58 ms 8024 KB Output is correct
13 Correct 51 ms 8020 KB Output is correct
14 Correct 51 ms 7892 KB Output is correct
15 Correct 53 ms 7884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4948 KB Output is correct
2 Correct 40 ms 5020 KB Output is correct
3 Correct 41 ms 5116 KB Output is correct
4 Correct 43 ms 5996 KB Output is correct
5 Correct 45 ms 6868 KB Output is correct
6 Correct 53 ms 8024 KB Output is correct
7 Correct 55 ms 7984 KB Output is correct
8 Correct 58 ms 7924 KB Output is correct
9 Correct 58 ms 7876 KB Output is correct
10 Correct 52 ms 7900 KB Output is correct
11 Correct 51 ms 8008 KB Output is correct
12 Correct 58 ms 8024 KB Output is correct
13 Correct 51 ms 8020 KB Output is correct
14 Correct 51 ms 7892 KB Output is correct
15 Correct 53 ms 7884 KB Output is correct
16 Correct 34 ms 5036 KB Output is correct
17 Correct 40 ms 4940 KB Output is correct
18 Correct 34 ms 5076 KB Output is correct
19 Correct 48 ms 6072 KB Output is correct
20 Correct 51 ms 7120 KB Output is correct
21 Correct 54 ms 8132 KB Output is correct
22 Correct 57 ms 8144 KB Output is correct
23 Correct 56 ms 8140 KB Output is correct
24 Correct 52 ms 8148 KB Output is correct
25 Correct 51 ms 8152 KB Output is correct
26 Correct 60 ms 8140 KB Output is correct
27 Correct 61 ms 8140 KB Output is correct
28 Correct 54 ms 8020 KB Output is correct
29 Correct 52 ms 8020 KB Output is correct
30 Correct 52 ms 8056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4948 KB Output is correct
2 Correct 40 ms 5020 KB Output is correct
3 Correct 41 ms 5116 KB Output is correct
4 Correct 43 ms 5996 KB Output is correct
5 Correct 45 ms 6868 KB Output is correct
6 Correct 53 ms 8024 KB Output is correct
7 Correct 55 ms 7984 KB Output is correct
8 Correct 58 ms 7924 KB Output is correct
9 Correct 58 ms 7876 KB Output is correct
10 Correct 52 ms 7900 KB Output is correct
11 Correct 51 ms 8008 KB Output is correct
12 Correct 58 ms 8024 KB Output is correct
13 Correct 51 ms 8020 KB Output is correct
14 Correct 51 ms 7892 KB Output is correct
15 Correct 53 ms 7884 KB Output is correct
16 Correct 34 ms 5036 KB Output is correct
17 Correct 40 ms 4940 KB Output is correct
18 Correct 34 ms 5076 KB Output is correct
19 Correct 48 ms 6072 KB Output is correct
20 Correct 51 ms 7120 KB Output is correct
21 Correct 54 ms 8132 KB Output is correct
22 Correct 57 ms 8144 KB Output is correct
23 Correct 56 ms 8140 KB Output is correct
24 Correct 52 ms 8148 KB Output is correct
25 Correct 51 ms 8152 KB Output is correct
26 Correct 60 ms 8140 KB Output is correct
27 Correct 61 ms 8140 KB Output is correct
28 Correct 54 ms 8020 KB Output is correct
29 Correct 52 ms 8020 KB Output is correct
30 Correct 52 ms 8056 KB Output is correct
31 Correct 35 ms 4948 KB Output is correct
32 Correct 36 ms 5028 KB Output is correct
33 Correct 41 ms 5024 KB Output is correct
34 Correct 47 ms 5196 KB Output is correct
35 Correct 43 ms 5132 KB Output is correct
36 Correct 34 ms 5076 KB Output is correct
37 Correct 38 ms 5588 KB Output is correct
38 Correct 38 ms 5600 KB Output is correct
39 Correct 41 ms 6100 KB Output is correct
40 Correct 52 ms 7252 KB Output is correct
41 Correct 59 ms 8152 KB Output is correct
42 Correct 55 ms 8144 KB Output is correct
43 Correct 59 ms 8140 KB Output is correct
44 Correct 60 ms 8088 KB Output is correct
45 Correct 59 ms 8228 KB Output is correct
46 Correct 59 ms 8144 KB Output is correct
47 Correct 55 ms 8140 KB Output is correct
48 Correct 54 ms 8140 KB Output is correct
49 Correct 57 ms 8088 KB Output is correct
50 Correct 56 ms 8140 KB Output is correct
51 Correct 56 ms 8144 KB Output is correct
52 Correct 61 ms 8140 KB Output is correct
53 Correct 54 ms 8036 KB Output is correct
54 Correct 57 ms 8144 KB Output is correct
55 Correct 60 ms 8140 KB Output is correct
56 Correct 58 ms 8084 KB Output is correct
57 Correct 60 ms 8092 KB Output is correct
58 Correct 57 ms 8144 KB Output is correct
59 Correct 55 ms 8144 KB Output is correct
60 Correct 63 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4948 KB Output is correct
2 Correct 36 ms 4948 KB Output is correct
3 Correct 37 ms 4948 KB Output is correct
4 Correct 36 ms 4936 KB Output is correct
5 Correct 35 ms 4936 KB Output is correct
6 Correct 34 ms 4936 KB Output is correct
7 Correct 38 ms 4948 KB Output is correct
8 Correct 40 ms 4948 KB Output is correct
9 Correct 35 ms 4948 KB Output is correct
10 Correct 34 ms 4936 KB Output is correct
11 Correct 35 ms 4948 KB Output is correct
12 Correct 40 ms 5020 KB Output is correct
13 Correct 41 ms 5116 KB Output is correct
14 Correct 43 ms 5996 KB Output is correct
15 Correct 45 ms 6868 KB Output is correct
16 Correct 53 ms 8024 KB Output is correct
17 Correct 55 ms 7984 KB Output is correct
18 Correct 58 ms 7924 KB Output is correct
19 Correct 58 ms 7876 KB Output is correct
20 Correct 52 ms 7900 KB Output is correct
21 Correct 51 ms 8008 KB Output is correct
22 Correct 58 ms 8024 KB Output is correct
23 Correct 51 ms 8020 KB Output is correct
24 Correct 51 ms 7892 KB Output is correct
25 Correct 53 ms 7884 KB Output is correct
26 Correct 34 ms 5036 KB Output is correct
27 Correct 40 ms 4940 KB Output is correct
28 Correct 34 ms 5076 KB Output is correct
29 Correct 48 ms 6072 KB Output is correct
30 Correct 51 ms 7120 KB Output is correct
31 Correct 54 ms 8132 KB Output is correct
32 Correct 57 ms 8144 KB Output is correct
33 Correct 56 ms 8140 KB Output is correct
34 Correct 52 ms 8148 KB Output is correct
35 Correct 51 ms 8152 KB Output is correct
36 Correct 60 ms 8140 KB Output is correct
37 Correct 61 ms 8140 KB Output is correct
38 Correct 54 ms 8020 KB Output is correct
39 Correct 52 ms 8020 KB Output is correct
40 Correct 52 ms 8056 KB Output is correct
41 Correct 35 ms 4948 KB Output is correct
42 Correct 36 ms 5028 KB Output is correct
43 Correct 41 ms 5024 KB Output is correct
44 Correct 47 ms 5196 KB Output is correct
45 Correct 43 ms 5132 KB Output is correct
46 Correct 34 ms 5076 KB Output is correct
47 Correct 38 ms 5588 KB Output is correct
48 Correct 38 ms 5600 KB Output is correct
49 Correct 41 ms 6100 KB Output is correct
50 Correct 52 ms 7252 KB Output is correct
51 Correct 59 ms 8152 KB Output is correct
52 Correct 55 ms 8144 KB Output is correct
53 Correct 59 ms 8140 KB Output is correct
54 Correct 60 ms 8088 KB Output is correct
55 Correct 59 ms 8228 KB Output is correct
56 Correct 59 ms 8144 KB Output is correct
57 Correct 55 ms 8140 KB Output is correct
58 Correct 54 ms 8140 KB Output is correct
59 Correct 57 ms 8088 KB Output is correct
60 Correct 56 ms 8140 KB Output is correct
61 Correct 56 ms 8144 KB Output is correct
62 Correct 61 ms 8140 KB Output is correct
63 Correct 54 ms 8036 KB Output is correct
64 Correct 57 ms 8144 KB Output is correct
65 Correct 60 ms 8140 KB Output is correct
66 Correct 58 ms 8084 KB Output is correct
67 Correct 60 ms 8092 KB Output is correct
68 Correct 57 ms 8144 KB Output is correct
69 Correct 55 ms 8144 KB Output is correct
70 Correct 63 ms 8140 KB Output is correct
71 Correct 41 ms 5588 KB Output is correct
72 Correct 40 ms 5628 KB Output is correct
73 Correct 46 ms 5588 KB Output is correct
74 Correct 38 ms 5588 KB Output is correct
75 Correct 39 ms 5588 KB Output is correct
76 Correct 42 ms 6268 KB Output is correct
77 Correct 42 ms 6228 KB Output is correct
78 Correct 42 ms 6232 KB Output is correct
79 Correct 42 ms 6264 KB Output is correct
80 Correct 41 ms 6228 KB Output is correct
81 Correct 61 ms 7336 KB Output is correct
82 Correct 54 ms 7248 KB Output is correct
83 Correct 50 ms 7364 KB Output is correct
84 Correct 50 ms 7360 KB Output is correct
85 Correct 55 ms 7360 KB Output is correct
86 Correct 53 ms 7312 KB Output is correct
87 Correct 58 ms 7536 KB Output is correct
88 Correct 52 ms 7280 KB Output is correct
89 Correct 54 ms 7244 KB Output is correct
90 Correct 56 ms 7288 KB Output is correct
91 Correct 60 ms 8080 KB Output is correct
92 Correct 67 ms 8168 KB Output is correct
93 Correct 61 ms 8060 KB Output is correct
94 Correct 64 ms 8024 KB Output is correct
95 Correct 59 ms 8144 KB Output is correct
96 Correct 63 ms 8088 KB Output is correct
97 Correct 57 ms 8180 KB Output is correct
98 Correct 59 ms 8084 KB Output is correct
99 Correct 58 ms 8200 KB Output is correct
100 Correct 53 ms 8036 KB Output is correct
101 Correct 67 ms 8136 KB Output is correct
102 Correct 55 ms 8128 KB Output is correct
103 Correct 62 ms 8080 KB Output is correct
104 Correct 68 ms 8160 KB Output is correct
105 Correct 50 ms 8076 KB Output is correct
106 Correct 52 ms 8268 KB Output is correct
107 Correct 59 ms 8092 KB Output is correct
108 Correct 57 ms 8036 KB Output is correct
109 Correct 54 ms 8068 KB Output is correct
110 Correct 58 ms 8076 KB Output is correct
111 Correct 54 ms 8112 KB Output is correct
112 Correct 58 ms 8148 KB Output is correct
113 Correct 53 ms 8108 KB Output is correct
114 Correct 54 ms 8260 KB Output is correct
115 Correct 56 ms 8144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4948 KB Output is correct
2 Correct 36 ms 4948 KB Output is correct
3 Correct 37 ms 4948 KB Output is correct
4 Correct 36 ms 4936 KB Output is correct
5 Correct 35 ms 4936 KB Output is correct
6 Correct 34 ms 4936 KB Output is correct
7 Correct 38 ms 4948 KB Output is correct
8 Correct 40 ms 4948 KB Output is correct
9 Correct 35 ms 4948 KB Output is correct
10 Correct 34 ms 4936 KB Output is correct
11 Correct 35 ms 4948 KB Output is correct
12 Correct 40 ms 5020 KB Output is correct
13 Correct 41 ms 5116 KB Output is correct
14 Correct 43 ms 5996 KB Output is correct
15 Correct 45 ms 6868 KB Output is correct
16 Correct 53 ms 8024 KB Output is correct
17 Correct 55 ms 7984 KB Output is correct
18 Correct 58 ms 7924 KB Output is correct
19 Correct 58 ms 7876 KB Output is correct
20 Correct 52 ms 7900 KB Output is correct
21 Correct 51 ms 8008 KB Output is correct
22 Correct 58 ms 8024 KB Output is correct
23 Correct 51 ms 8020 KB Output is correct
24 Correct 51 ms 7892 KB Output is correct
25 Correct 53 ms 7884 KB Output is correct
26 Correct 34 ms 5036 KB Output is correct
27 Correct 40 ms 4940 KB Output is correct
28 Correct 34 ms 5076 KB Output is correct
29 Correct 48 ms 6072 KB Output is correct
30 Correct 51 ms 7120 KB Output is correct
31 Correct 54 ms 8132 KB Output is correct
32 Correct 57 ms 8144 KB Output is correct
33 Correct 56 ms 8140 KB Output is correct
34 Correct 52 ms 8148 KB Output is correct
35 Correct 51 ms 8152 KB Output is correct
36 Correct 60 ms 8140 KB Output is correct
37 Correct 61 ms 8140 KB Output is correct
38 Correct 54 ms 8020 KB Output is correct
39 Correct 52 ms 8020 KB Output is correct
40 Correct 52 ms 8056 KB Output is correct
41 Correct 35 ms 4948 KB Output is correct
42 Correct 36 ms 5028 KB Output is correct
43 Correct 41 ms 5024 KB Output is correct
44 Correct 47 ms 5196 KB Output is correct
45 Correct 43 ms 5132 KB Output is correct
46 Correct 34 ms 5076 KB Output is correct
47 Correct 38 ms 5588 KB Output is correct
48 Correct 38 ms 5600 KB Output is correct
49 Correct 41 ms 6100 KB Output is correct
50 Correct 52 ms 7252 KB Output is correct
51 Correct 59 ms 8152 KB Output is correct
52 Correct 55 ms 8144 KB Output is correct
53 Correct 59 ms 8140 KB Output is correct
54 Correct 60 ms 8088 KB Output is correct
55 Correct 59 ms 8228 KB Output is correct
56 Correct 59 ms 8144 KB Output is correct
57 Correct 55 ms 8140 KB Output is correct
58 Correct 54 ms 8140 KB Output is correct
59 Correct 57 ms 8088 KB Output is correct
60 Correct 56 ms 8140 KB Output is correct
61 Correct 56 ms 8144 KB Output is correct
62 Correct 61 ms 8140 KB Output is correct
63 Correct 54 ms 8036 KB Output is correct
64 Correct 57 ms 8144 KB Output is correct
65 Correct 60 ms 8140 KB Output is correct
66 Correct 58 ms 8084 KB Output is correct
67 Correct 60 ms 8092 KB Output is correct
68 Correct 57 ms 8144 KB Output is correct
69 Correct 55 ms 8144 KB Output is correct
70 Correct 63 ms 8140 KB Output is correct
71 Correct 41 ms 5588 KB Output is correct
72 Correct 40 ms 5628 KB Output is correct
73 Correct 46 ms 5588 KB Output is correct
74 Correct 38 ms 5588 KB Output is correct
75 Correct 39 ms 5588 KB Output is correct
76 Correct 42 ms 6268 KB Output is correct
77 Correct 42 ms 6228 KB Output is correct
78 Correct 42 ms 6232 KB Output is correct
79 Correct 42 ms 6264 KB Output is correct
80 Correct 41 ms 6228 KB Output is correct
81 Correct 61 ms 7336 KB Output is correct
82 Correct 54 ms 7248 KB Output is correct
83 Correct 50 ms 7364 KB Output is correct
84 Correct 50 ms 7360 KB Output is correct
85 Correct 55 ms 7360 KB Output is correct
86 Correct 53 ms 7312 KB Output is correct
87 Correct 58 ms 7536 KB Output is correct
88 Correct 52 ms 7280 KB Output is correct
89 Correct 54 ms 7244 KB Output is correct
90 Correct 56 ms 7288 KB Output is correct
91 Correct 60 ms 8080 KB Output is correct
92 Correct 67 ms 8168 KB Output is correct
93 Correct 61 ms 8060 KB Output is correct
94 Correct 64 ms 8024 KB Output is correct
95 Correct 59 ms 8144 KB Output is correct
96 Correct 63 ms 8088 KB Output is correct
97 Correct 57 ms 8180 KB Output is correct
98 Correct 59 ms 8084 KB Output is correct
99 Correct 58 ms 8200 KB Output is correct
100 Correct 53 ms 8036 KB Output is correct
101 Correct 67 ms 8136 KB Output is correct
102 Correct 55 ms 8128 KB Output is correct
103 Correct 62 ms 8080 KB Output is correct
104 Correct 68 ms 8160 KB Output is correct
105 Correct 50 ms 8076 KB Output is correct
106 Correct 52 ms 8268 KB Output is correct
107 Correct 59 ms 8092 KB Output is correct
108 Correct 57 ms 8036 KB Output is correct
109 Correct 54 ms 8068 KB Output is correct
110 Correct 58 ms 8076 KB Output is correct
111 Correct 54 ms 8112 KB Output is correct
112 Correct 58 ms 8148 KB Output is correct
113 Correct 53 ms 8108 KB Output is correct
114 Correct 54 ms 8260 KB Output is correct
115 Correct 56 ms 8144 KB Output is correct
116 Incorrect 36 ms 5204 KB Output isn't correct
117 Halted 0 ms 0 KB -