Submission #881887

# Submission time Handle Problem Language Result Execution time Memory
881887 2023-12-02T07:51:45 Z TAhmed33 Diversity (CEOI21_diversity) C++
64 / 100
102 ms 6796 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3e5 + 25;
int n, a[MAXN], q, n1;
int freq[MAXN];
int main () {
	cin >> n >> q;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	for (auto i : a) freq[i]++;
	vector <int> x;	
	for (int i = 1; i < MAXN; i++) {
		if (freq[i]) {
			x.push_back(freq[i]);
		}
	}
	int n1 = x.size();
	sort(x.begin(), x.end());
	deque <int> y;
	for (int i = n1 - 1; i >= 0; i -= 2) y.push_front(x[i]);
	for (int i = n1 - 2; i >= 0; i -= 2) y.push_back(x[i]);
	ll mn = 1e18;
	ll r = 0, sum = 0;
	for (auto i : y) {
		sum += r * (r + 1) / 2 + (n - i - r) * (n - i - r + 1) / 2;
		r += i;
	}
	sum = ll(n) * ll((n + 1)) / 2 * ((ll)y.size()) - sum;
	mn = sum;
	cout << mn << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2496 KB Output is correct
4 Correct 13 ms 2492 KB Output is correct
5 Correct 25 ms 2396 KB Output is correct
6 Correct 42 ms 2588 KB Output is correct
7 Correct 38 ms 2392 KB Output is correct
8 Correct 39 ms 2392 KB Output is correct
9 Correct 39 ms 2396 KB Output is correct
10 Correct 39 ms 2488 KB Output is correct
11 Correct 41 ms 2396 KB Output is correct
12 Correct 40 ms 2396 KB Output is correct
13 Correct 39 ms 2480 KB Output is correct
14 Correct 39 ms 2392 KB Output is correct
15 Correct 39 ms 2484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2496 KB Output is correct
4 Correct 13 ms 2492 KB Output is correct
5 Correct 25 ms 2396 KB Output is correct
6 Correct 42 ms 2588 KB Output is correct
7 Correct 38 ms 2392 KB Output is correct
8 Correct 39 ms 2392 KB Output is correct
9 Correct 39 ms 2396 KB Output is correct
10 Correct 39 ms 2488 KB Output is correct
11 Correct 41 ms 2396 KB Output is correct
12 Correct 40 ms 2396 KB Output is correct
13 Correct 39 ms 2480 KB Output is correct
14 Correct 39 ms 2392 KB Output is correct
15 Correct 39 ms 2484 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 3 ms 2500 KB Output is correct
19 Correct 16 ms 2740 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 44 ms 3292 KB Output is correct
22 Correct 44 ms 3240 KB Output is correct
23 Correct 44 ms 3152 KB Output is correct
24 Correct 54 ms 3664 KB Output is correct
25 Correct 44 ms 3156 KB Output is correct
26 Correct 44 ms 3244 KB Output is correct
27 Correct 44 ms 3300 KB Output is correct
28 Correct 43 ms 3232 KB Output is correct
29 Correct 43 ms 3156 KB Output is correct
30 Correct 56 ms 3296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2496 KB Output is correct
4 Correct 13 ms 2492 KB Output is correct
5 Correct 25 ms 2396 KB Output is correct
6 Correct 42 ms 2588 KB Output is correct
7 Correct 38 ms 2392 KB Output is correct
8 Correct 39 ms 2392 KB Output is correct
9 Correct 39 ms 2396 KB Output is correct
10 Correct 39 ms 2488 KB Output is correct
11 Correct 41 ms 2396 KB Output is correct
12 Correct 40 ms 2396 KB Output is correct
13 Correct 39 ms 2480 KB Output is correct
14 Correct 39 ms 2392 KB Output is correct
15 Correct 39 ms 2484 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 3 ms 2500 KB Output is correct
19 Correct 16 ms 2740 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 44 ms 3292 KB Output is correct
22 Correct 44 ms 3240 KB Output is correct
23 Correct 44 ms 3152 KB Output is correct
24 Correct 54 ms 3664 KB Output is correct
25 Correct 44 ms 3156 KB Output is correct
26 Correct 44 ms 3244 KB Output is correct
27 Correct 44 ms 3300 KB Output is correct
28 Correct 43 ms 3232 KB Output is correct
29 Correct 43 ms 3156 KB Output is correct
30 Correct 56 ms 3296 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2396 KB Output is correct
34 Correct 3 ms 2392 KB Output is correct
35 Correct 3 ms 2396 KB Output is correct
36 Correct 3 ms 2396 KB Output is correct
37 Correct 10 ms 2676 KB Output is correct
38 Correct 10 ms 2652 KB Output is correct
39 Correct 20 ms 2728 KB Output is correct
40 Correct 38 ms 3164 KB Output is correct
41 Correct 56 ms 3620 KB Output is correct
42 Correct 67 ms 3732 KB Output is correct
43 Correct 56 ms 3664 KB Output is correct
44 Correct 56 ms 3668 KB Output is correct
45 Correct 56 ms 3620 KB Output is correct
46 Correct 56 ms 3736 KB Output is correct
47 Correct 56 ms 3604 KB Output is correct
48 Correct 61 ms 3668 KB Output is correct
49 Correct 56 ms 3668 KB Output is correct
50 Correct 64 ms 3668 KB Output is correct
51 Correct 55 ms 3752 KB Output is correct
52 Correct 57 ms 3612 KB Output is correct
53 Correct 58 ms 4000 KB Output is correct
54 Correct 56 ms 3664 KB Output is correct
55 Correct 56 ms 3668 KB Output is correct
56 Correct 58 ms 3732 KB Output is correct
57 Correct 58 ms 3668 KB Output is correct
58 Correct 56 ms 3664 KB Output is correct
59 Correct 56 ms 3668 KB Output is correct
60 Correct 56 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 2 ms 2496 KB Output is correct
14 Correct 13 ms 2492 KB Output is correct
15 Correct 25 ms 2396 KB Output is correct
16 Correct 42 ms 2588 KB Output is correct
17 Correct 38 ms 2392 KB Output is correct
18 Correct 39 ms 2392 KB Output is correct
19 Correct 39 ms 2396 KB Output is correct
20 Correct 39 ms 2488 KB Output is correct
21 Correct 41 ms 2396 KB Output is correct
22 Correct 40 ms 2396 KB Output is correct
23 Correct 39 ms 2480 KB Output is correct
24 Correct 39 ms 2392 KB Output is correct
25 Correct 39 ms 2484 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 3 ms 2500 KB Output is correct
29 Correct 16 ms 2740 KB Output is correct
30 Correct 30 ms 2904 KB Output is correct
31 Correct 44 ms 3292 KB Output is correct
32 Correct 44 ms 3240 KB Output is correct
33 Correct 44 ms 3152 KB Output is correct
34 Correct 54 ms 3664 KB Output is correct
35 Correct 44 ms 3156 KB Output is correct
36 Correct 44 ms 3244 KB Output is correct
37 Correct 44 ms 3300 KB Output is correct
38 Correct 43 ms 3232 KB Output is correct
39 Correct 43 ms 3156 KB Output is correct
40 Correct 56 ms 3296 KB Output is correct
41 Correct 2 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 3 ms 2392 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 3 ms 2396 KB Output is correct
47 Correct 10 ms 2676 KB Output is correct
48 Correct 10 ms 2652 KB Output is correct
49 Correct 20 ms 2728 KB Output is correct
50 Correct 38 ms 3164 KB Output is correct
51 Correct 56 ms 3620 KB Output is correct
52 Correct 67 ms 3732 KB Output is correct
53 Correct 56 ms 3664 KB Output is correct
54 Correct 56 ms 3668 KB Output is correct
55 Correct 56 ms 3620 KB Output is correct
56 Correct 56 ms 3736 KB Output is correct
57 Correct 56 ms 3604 KB Output is correct
58 Correct 61 ms 3668 KB Output is correct
59 Correct 56 ms 3668 KB Output is correct
60 Correct 64 ms 3668 KB Output is correct
61 Correct 55 ms 3752 KB Output is correct
62 Correct 57 ms 3612 KB Output is correct
63 Correct 58 ms 4000 KB Output is correct
64 Correct 56 ms 3664 KB Output is correct
65 Correct 56 ms 3668 KB Output is correct
66 Correct 58 ms 3732 KB Output is correct
67 Correct 58 ms 3668 KB Output is correct
68 Correct 56 ms 3664 KB Output is correct
69 Correct 56 ms 3668 KB Output is correct
70 Correct 56 ms 3668 KB Output is correct
71 Correct 12 ms 2648 KB Output is correct
72 Correct 15 ms 2652 KB Output is correct
73 Correct 12 ms 2716 KB Output is correct
74 Correct 12 ms 2652 KB Output is correct
75 Correct 11 ms 2652 KB Output is correct
76 Correct 23 ms 2948 KB Output is correct
77 Correct 27 ms 3208 KB Output is correct
78 Correct 23 ms 2908 KB Output is correct
79 Correct 23 ms 2864 KB Output is correct
80 Correct 23 ms 2908 KB Output is correct
81 Correct 46 ms 3412 KB Output is correct
82 Correct 47 ms 3424 KB Output is correct
83 Correct 46 ms 3372 KB Output is correct
84 Correct 46 ms 3428 KB Output is correct
85 Correct 52 ms 3368 KB Output is correct
86 Correct 49 ms 3664 KB Output is correct
87 Correct 49 ms 3616 KB Output is correct
88 Correct 49 ms 3668 KB Output is correct
89 Correct 49 ms 3620 KB Output is correct
90 Correct 61 ms 3612 KB Output is correct
91 Correct 80 ms 5272 KB Output is correct
92 Correct 79 ms 5264 KB Output is correct
93 Correct 84 ms 5068 KB Output is correct
94 Correct 80 ms 5204 KB Output is correct
95 Correct 79 ms 5072 KB Output is correct
96 Correct 89 ms 6128 KB Output is correct
97 Correct 100 ms 6272 KB Output is correct
98 Correct 85 ms 6040 KB Output is correct
99 Correct 84 ms 6088 KB Output is correct
100 Correct 89 ms 6088 KB Output is correct
101 Correct 85 ms 6168 KB Output is correct
102 Correct 102 ms 6084 KB Output is correct
103 Correct 85 ms 6160 KB Output is correct
104 Correct 85 ms 6084 KB Output is correct
105 Correct 85 ms 6528 KB Output is correct
106 Correct 86 ms 6596 KB Output is correct
107 Correct 95 ms 6796 KB Output is correct
108 Correct 86 ms 6596 KB Output is correct
109 Correct 85 ms 6680 KB Output is correct
110 Correct 87 ms 6600 KB Output is correct
111 Correct 87 ms 6668 KB Output is correct
112 Correct 86 ms 6600 KB Output is correct
113 Correct 86 ms 6600 KB Output is correct
114 Correct 93 ms 6600 KB Output is correct
115 Correct 86 ms 6596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2492 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 2 ms 2496 KB Output is correct
14 Correct 13 ms 2492 KB Output is correct
15 Correct 25 ms 2396 KB Output is correct
16 Correct 42 ms 2588 KB Output is correct
17 Correct 38 ms 2392 KB Output is correct
18 Correct 39 ms 2392 KB Output is correct
19 Correct 39 ms 2396 KB Output is correct
20 Correct 39 ms 2488 KB Output is correct
21 Correct 41 ms 2396 KB Output is correct
22 Correct 40 ms 2396 KB Output is correct
23 Correct 39 ms 2480 KB Output is correct
24 Correct 39 ms 2392 KB Output is correct
25 Correct 39 ms 2484 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 3 ms 2500 KB Output is correct
29 Correct 16 ms 2740 KB Output is correct
30 Correct 30 ms 2904 KB Output is correct
31 Correct 44 ms 3292 KB Output is correct
32 Correct 44 ms 3240 KB Output is correct
33 Correct 44 ms 3152 KB Output is correct
34 Correct 54 ms 3664 KB Output is correct
35 Correct 44 ms 3156 KB Output is correct
36 Correct 44 ms 3244 KB Output is correct
37 Correct 44 ms 3300 KB Output is correct
38 Correct 43 ms 3232 KB Output is correct
39 Correct 43 ms 3156 KB Output is correct
40 Correct 56 ms 3296 KB Output is correct
41 Correct 2 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 3 ms 2392 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 3 ms 2396 KB Output is correct
47 Correct 10 ms 2676 KB Output is correct
48 Correct 10 ms 2652 KB Output is correct
49 Correct 20 ms 2728 KB Output is correct
50 Correct 38 ms 3164 KB Output is correct
51 Correct 56 ms 3620 KB Output is correct
52 Correct 67 ms 3732 KB Output is correct
53 Correct 56 ms 3664 KB Output is correct
54 Correct 56 ms 3668 KB Output is correct
55 Correct 56 ms 3620 KB Output is correct
56 Correct 56 ms 3736 KB Output is correct
57 Correct 56 ms 3604 KB Output is correct
58 Correct 61 ms 3668 KB Output is correct
59 Correct 56 ms 3668 KB Output is correct
60 Correct 64 ms 3668 KB Output is correct
61 Correct 55 ms 3752 KB Output is correct
62 Correct 57 ms 3612 KB Output is correct
63 Correct 58 ms 4000 KB Output is correct
64 Correct 56 ms 3664 KB Output is correct
65 Correct 56 ms 3668 KB Output is correct
66 Correct 58 ms 3732 KB Output is correct
67 Correct 58 ms 3668 KB Output is correct
68 Correct 56 ms 3664 KB Output is correct
69 Correct 56 ms 3668 KB Output is correct
70 Correct 56 ms 3668 KB Output is correct
71 Correct 12 ms 2648 KB Output is correct
72 Correct 15 ms 2652 KB Output is correct
73 Correct 12 ms 2716 KB Output is correct
74 Correct 12 ms 2652 KB Output is correct
75 Correct 11 ms 2652 KB Output is correct
76 Correct 23 ms 2948 KB Output is correct
77 Correct 27 ms 3208 KB Output is correct
78 Correct 23 ms 2908 KB Output is correct
79 Correct 23 ms 2864 KB Output is correct
80 Correct 23 ms 2908 KB Output is correct
81 Correct 46 ms 3412 KB Output is correct
82 Correct 47 ms 3424 KB Output is correct
83 Correct 46 ms 3372 KB Output is correct
84 Correct 46 ms 3428 KB Output is correct
85 Correct 52 ms 3368 KB Output is correct
86 Correct 49 ms 3664 KB Output is correct
87 Correct 49 ms 3616 KB Output is correct
88 Correct 49 ms 3668 KB Output is correct
89 Correct 49 ms 3620 KB Output is correct
90 Correct 61 ms 3612 KB Output is correct
91 Correct 80 ms 5272 KB Output is correct
92 Correct 79 ms 5264 KB Output is correct
93 Correct 84 ms 5068 KB Output is correct
94 Correct 80 ms 5204 KB Output is correct
95 Correct 79 ms 5072 KB Output is correct
96 Correct 89 ms 6128 KB Output is correct
97 Correct 100 ms 6272 KB Output is correct
98 Correct 85 ms 6040 KB Output is correct
99 Correct 84 ms 6088 KB Output is correct
100 Correct 89 ms 6088 KB Output is correct
101 Correct 85 ms 6168 KB Output is correct
102 Correct 102 ms 6084 KB Output is correct
103 Correct 85 ms 6160 KB Output is correct
104 Correct 85 ms 6084 KB Output is correct
105 Correct 85 ms 6528 KB Output is correct
106 Correct 86 ms 6596 KB Output is correct
107 Correct 95 ms 6796 KB Output is correct
108 Correct 86 ms 6596 KB Output is correct
109 Correct 85 ms 6680 KB Output is correct
110 Correct 87 ms 6600 KB Output is correct
111 Correct 87 ms 6668 KB Output is correct
112 Correct 86 ms 6600 KB Output is correct
113 Correct 86 ms 6600 KB Output is correct
114 Correct 93 ms 6600 KB Output is correct
115 Correct 86 ms 6596 KB Output is correct
116 Incorrect 3 ms 2396 KB Output isn't correct
117 Halted 0 ms 0 KB -