Submission #576336

# Submission time Handle Problem Language Result Execution time Memory
576336 2022-06-13T03:33:53 Z amunduzbaev Diversity (CEOI21_diversity) C++17
64 / 100
74 ms 10988 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
#define int long long

const int N = 3e5 + 5;
int cc[N];

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, q; cin>>n>>q;
	vector<int> a(n), b;
	for(int i=0;i<n;i++) cin>>a[i];
	b = a;
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	int m = b.size();
	for(int i=0;i<n;i++){
		cc[a[i]]++;
	}
	
	sort(b.begin(), b.end(), [&](int i, int j){
		return (cc[i] > cc[j]);
	});
	deque<int> c;
	for(int i=0;i<m;i++){
		if(i & 1) c.push_back(cc[b[i]]);
		else c.push_front(cc[b[i]]);
	}
	
	//~ for(int i=0;i<n;i++) cout<<c[i]<<" ";
	//~ cout<<"\n";
	int res = n * (n + 1) / 2;
	int ajj = 0, aj = 0;
	for(int i=0;i<m;i++){
		res = res + c[i] * i * aj - c[i] * ajj;
		aj += c[i];
		ajj += c[i] * i;
	}
	
	cout<<res<<"\n";
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 8 ms 2104 KB Output is correct
5 Correct 16 ms 3840 KB Output is correct
6 Correct 26 ms 5612 KB Output is correct
7 Correct 24 ms 5612 KB Output is correct
8 Correct 25 ms 5620 KB Output is correct
9 Correct 32 ms 5588 KB Output is correct
10 Correct 27 ms 5616 KB Output is correct
11 Correct 27 ms 5604 KB Output is correct
12 Correct 26 ms 5612 KB Output is correct
13 Correct 26 ms 5604 KB Output is correct
14 Correct 26 ms 5528 KB Output is correct
15 Correct 25 ms 5612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 8 ms 2104 KB Output is correct
5 Correct 16 ms 3840 KB Output is correct
6 Correct 26 ms 5612 KB Output is correct
7 Correct 24 ms 5612 KB Output is correct
8 Correct 25 ms 5620 KB Output is correct
9 Correct 32 ms 5588 KB Output is correct
10 Correct 27 ms 5616 KB Output is correct
11 Correct 27 ms 5604 KB Output is correct
12 Correct 26 ms 5612 KB Output is correct
13 Correct 26 ms 5604 KB Output is correct
14 Correct 26 ms 5528 KB Output is correct
15 Correct 25 ms 5612 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 10 ms 2132 KB Output is correct
20 Correct 18 ms 3972 KB Output is correct
21 Correct 32 ms 5844 KB Output is correct
22 Correct 30 ms 5724 KB Output is correct
23 Correct 35 ms 5780 KB Output is correct
24 Correct 29 ms 5820 KB Output is correct
25 Correct 27 ms 5760 KB Output is correct
26 Correct 30 ms 5716 KB Output is correct
27 Correct 27 ms 5716 KB Output is correct
28 Correct 27 ms 5756 KB Output is correct
29 Correct 26 ms 5712 KB Output is correct
30 Correct 36 ms 5788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 8 ms 2104 KB Output is correct
5 Correct 16 ms 3840 KB Output is correct
6 Correct 26 ms 5612 KB Output is correct
7 Correct 24 ms 5612 KB Output is correct
8 Correct 25 ms 5620 KB Output is correct
9 Correct 32 ms 5588 KB Output is correct
10 Correct 27 ms 5616 KB Output is correct
11 Correct 27 ms 5604 KB Output is correct
12 Correct 26 ms 5612 KB Output is correct
13 Correct 26 ms 5604 KB Output is correct
14 Correct 26 ms 5528 KB Output is correct
15 Correct 25 ms 5612 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 10 ms 2132 KB Output is correct
20 Correct 18 ms 3972 KB Output is correct
21 Correct 32 ms 5844 KB Output is correct
22 Correct 30 ms 5724 KB Output is correct
23 Correct 35 ms 5780 KB Output is correct
24 Correct 29 ms 5820 KB Output is correct
25 Correct 27 ms 5760 KB Output is correct
26 Correct 30 ms 5716 KB Output is correct
27 Correct 27 ms 5716 KB Output is correct
28 Correct 27 ms 5756 KB Output is correct
29 Correct 26 ms 5712 KB Output is correct
30 Correct 36 ms 5788 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 6 ms 1236 KB Output is correct
38 Correct 10 ms 1232 KB Output is correct
39 Correct 13 ms 2264 KB Output is correct
40 Correct 23 ms 4224 KB Output is correct
41 Correct 36 ms 6092 KB Output is correct
42 Correct 42 ms 6116 KB Output is correct
43 Correct 38 ms 6156 KB Output is correct
44 Correct 36 ms 6096 KB Output is correct
45 Correct 38 ms 6120 KB Output is correct
46 Correct 34 ms 6108 KB Output is correct
47 Correct 36 ms 6108 KB Output is correct
48 Correct 34 ms 6120 KB Output is correct
49 Correct 37 ms 6120 KB Output is correct
50 Correct 35 ms 6116 KB Output is correct
51 Correct 40 ms 6116 KB Output is correct
52 Correct 34 ms 6128 KB Output is correct
53 Correct 35 ms 6092 KB Output is correct
54 Correct 34 ms 6092 KB Output is correct
55 Correct 35 ms 6120 KB Output is correct
56 Correct 35 ms 6112 KB Output is correct
57 Correct 37 ms 6156 KB Output is correct
58 Correct 47 ms 6120 KB Output is correct
59 Correct 47 ms 6220 KB Output is correct
60 Correct 35 ms 6120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 8 ms 2104 KB Output is correct
15 Correct 16 ms 3840 KB Output is correct
16 Correct 26 ms 5612 KB Output is correct
17 Correct 24 ms 5612 KB Output is correct
18 Correct 25 ms 5620 KB Output is correct
19 Correct 32 ms 5588 KB Output is correct
20 Correct 27 ms 5616 KB Output is correct
21 Correct 27 ms 5604 KB Output is correct
22 Correct 26 ms 5612 KB Output is correct
23 Correct 26 ms 5604 KB Output is correct
24 Correct 26 ms 5528 KB Output is correct
25 Correct 25 ms 5612 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 10 ms 2132 KB Output is correct
30 Correct 18 ms 3972 KB Output is correct
31 Correct 32 ms 5844 KB Output is correct
32 Correct 30 ms 5724 KB Output is correct
33 Correct 35 ms 5780 KB Output is correct
34 Correct 29 ms 5820 KB Output is correct
35 Correct 27 ms 5760 KB Output is correct
36 Correct 30 ms 5716 KB Output is correct
37 Correct 27 ms 5716 KB Output is correct
38 Correct 27 ms 5756 KB Output is correct
39 Correct 26 ms 5712 KB Output is correct
40 Correct 36 ms 5788 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 6 ms 1236 KB Output is correct
48 Correct 10 ms 1232 KB Output is correct
49 Correct 13 ms 2264 KB Output is correct
50 Correct 23 ms 4224 KB Output is correct
51 Correct 36 ms 6092 KB Output is correct
52 Correct 42 ms 6116 KB Output is correct
53 Correct 38 ms 6156 KB Output is correct
54 Correct 36 ms 6096 KB Output is correct
55 Correct 38 ms 6120 KB Output is correct
56 Correct 34 ms 6108 KB Output is correct
57 Correct 36 ms 6108 KB Output is correct
58 Correct 34 ms 6120 KB Output is correct
59 Correct 37 ms 6120 KB Output is correct
60 Correct 35 ms 6116 KB Output is correct
61 Correct 40 ms 6116 KB Output is correct
62 Correct 34 ms 6128 KB Output is correct
63 Correct 35 ms 6092 KB Output is correct
64 Correct 34 ms 6092 KB Output is correct
65 Correct 35 ms 6120 KB Output is correct
66 Correct 35 ms 6112 KB Output is correct
67 Correct 37 ms 6156 KB Output is correct
68 Correct 47 ms 6120 KB Output is correct
69 Correct 47 ms 6220 KB Output is correct
70 Correct 35 ms 6120 KB Output is correct
71 Correct 7 ms 1364 KB Output is correct
72 Correct 7 ms 1364 KB Output is correct
73 Correct 7 ms 1344 KB Output is correct
74 Correct 7 ms 1364 KB Output is correct
75 Correct 7 ms 1344 KB Output is correct
76 Correct 14 ms 2380 KB Output is correct
77 Correct 16 ms 2392 KB Output is correct
78 Correct 19 ms 2380 KB Output is correct
79 Correct 18 ms 2380 KB Output is correct
80 Correct 18 ms 2388 KB Output is correct
81 Correct 27 ms 4556 KB Output is correct
82 Correct 30 ms 4552 KB Output is correct
83 Correct 31 ms 4560 KB Output is correct
84 Correct 28 ms 4556 KB Output is correct
85 Correct 30 ms 4556 KB Output is correct
86 Correct 41 ms 4772 KB Output is correct
87 Correct 32 ms 4812 KB Output is correct
88 Correct 41 ms 4812 KB Output is correct
89 Correct 31 ms 4768 KB Output is correct
90 Correct 34 ms 4816 KB Output is correct
91 Correct 54 ms 8296 KB Output is correct
92 Correct 54 ms 8280 KB Output is correct
93 Correct 53 ms 8280 KB Output is correct
94 Correct 67 ms 8412 KB Output is correct
95 Correct 52 ms 8268 KB Output is correct
96 Correct 58 ms 10084 KB Output is correct
97 Correct 57 ms 10112 KB Output is correct
98 Correct 58 ms 10112 KB Output is correct
99 Correct 70 ms 10088 KB Output is correct
100 Correct 59 ms 10076 KB Output is correct
101 Correct 61 ms 10016 KB Output is correct
102 Correct 58 ms 10084 KB Output is correct
103 Correct 64 ms 10084 KB Output is correct
104 Correct 59 ms 10088 KB Output is correct
105 Correct 63 ms 10072 KB Output is correct
106 Correct 63 ms 10840 KB Output is correct
107 Correct 57 ms 10852 KB Output is correct
108 Correct 60 ms 10840 KB Output is correct
109 Correct 61 ms 10988 KB Output is correct
110 Correct 74 ms 10844 KB Output is correct
111 Correct 60 ms 10844 KB Output is correct
112 Correct 58 ms 10860 KB Output is correct
113 Correct 60 ms 10840 KB Output is correct
114 Correct 67 ms 10844 KB Output is correct
115 Correct 64 ms 10956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 8 ms 2104 KB Output is correct
15 Correct 16 ms 3840 KB Output is correct
16 Correct 26 ms 5612 KB Output is correct
17 Correct 24 ms 5612 KB Output is correct
18 Correct 25 ms 5620 KB Output is correct
19 Correct 32 ms 5588 KB Output is correct
20 Correct 27 ms 5616 KB Output is correct
21 Correct 27 ms 5604 KB Output is correct
22 Correct 26 ms 5612 KB Output is correct
23 Correct 26 ms 5604 KB Output is correct
24 Correct 26 ms 5528 KB Output is correct
25 Correct 25 ms 5612 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 10 ms 2132 KB Output is correct
30 Correct 18 ms 3972 KB Output is correct
31 Correct 32 ms 5844 KB Output is correct
32 Correct 30 ms 5724 KB Output is correct
33 Correct 35 ms 5780 KB Output is correct
34 Correct 29 ms 5820 KB Output is correct
35 Correct 27 ms 5760 KB Output is correct
36 Correct 30 ms 5716 KB Output is correct
37 Correct 27 ms 5716 KB Output is correct
38 Correct 27 ms 5756 KB Output is correct
39 Correct 26 ms 5712 KB Output is correct
40 Correct 36 ms 5788 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 6 ms 1236 KB Output is correct
48 Correct 10 ms 1232 KB Output is correct
49 Correct 13 ms 2264 KB Output is correct
50 Correct 23 ms 4224 KB Output is correct
51 Correct 36 ms 6092 KB Output is correct
52 Correct 42 ms 6116 KB Output is correct
53 Correct 38 ms 6156 KB Output is correct
54 Correct 36 ms 6096 KB Output is correct
55 Correct 38 ms 6120 KB Output is correct
56 Correct 34 ms 6108 KB Output is correct
57 Correct 36 ms 6108 KB Output is correct
58 Correct 34 ms 6120 KB Output is correct
59 Correct 37 ms 6120 KB Output is correct
60 Correct 35 ms 6116 KB Output is correct
61 Correct 40 ms 6116 KB Output is correct
62 Correct 34 ms 6128 KB Output is correct
63 Correct 35 ms 6092 KB Output is correct
64 Correct 34 ms 6092 KB Output is correct
65 Correct 35 ms 6120 KB Output is correct
66 Correct 35 ms 6112 KB Output is correct
67 Correct 37 ms 6156 KB Output is correct
68 Correct 47 ms 6120 KB Output is correct
69 Correct 47 ms 6220 KB Output is correct
70 Correct 35 ms 6120 KB Output is correct
71 Correct 7 ms 1364 KB Output is correct
72 Correct 7 ms 1364 KB Output is correct
73 Correct 7 ms 1344 KB Output is correct
74 Correct 7 ms 1364 KB Output is correct
75 Correct 7 ms 1344 KB Output is correct
76 Correct 14 ms 2380 KB Output is correct
77 Correct 16 ms 2392 KB Output is correct
78 Correct 19 ms 2380 KB Output is correct
79 Correct 18 ms 2380 KB Output is correct
80 Correct 18 ms 2388 KB Output is correct
81 Correct 27 ms 4556 KB Output is correct
82 Correct 30 ms 4552 KB Output is correct
83 Correct 31 ms 4560 KB Output is correct
84 Correct 28 ms 4556 KB Output is correct
85 Correct 30 ms 4556 KB Output is correct
86 Correct 41 ms 4772 KB Output is correct
87 Correct 32 ms 4812 KB Output is correct
88 Correct 41 ms 4812 KB Output is correct
89 Correct 31 ms 4768 KB Output is correct
90 Correct 34 ms 4816 KB Output is correct
91 Correct 54 ms 8296 KB Output is correct
92 Correct 54 ms 8280 KB Output is correct
93 Correct 53 ms 8280 KB Output is correct
94 Correct 67 ms 8412 KB Output is correct
95 Correct 52 ms 8268 KB Output is correct
96 Correct 58 ms 10084 KB Output is correct
97 Correct 57 ms 10112 KB Output is correct
98 Correct 58 ms 10112 KB Output is correct
99 Correct 70 ms 10088 KB Output is correct
100 Correct 59 ms 10076 KB Output is correct
101 Correct 61 ms 10016 KB Output is correct
102 Correct 58 ms 10084 KB Output is correct
103 Correct 64 ms 10084 KB Output is correct
104 Correct 59 ms 10088 KB Output is correct
105 Correct 63 ms 10072 KB Output is correct
106 Correct 63 ms 10840 KB Output is correct
107 Correct 57 ms 10852 KB Output is correct
108 Correct 60 ms 10840 KB Output is correct
109 Correct 61 ms 10988 KB Output is correct
110 Correct 74 ms 10844 KB Output is correct
111 Correct 60 ms 10844 KB Output is correct
112 Correct 58 ms 10860 KB Output is correct
113 Correct 60 ms 10840 KB Output is correct
114 Correct 67 ms 10844 KB Output is correct
115 Correct 64 ms 10956 KB Output is correct
116 Incorrect 2 ms 516 KB Output isn't correct
117 Halted 0 ms 0 KB -