# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068516 | 2024-08-21T10:24:36 Z | Andrey | Diversity (CEOI21_diversity) | C++14 | 37 ms | 7068 KB |
#include<bits/stdc++.h> using namespace std; vector<long long> br(300001); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,q; cin >> n >> q; long long ans = 0; vector<long long> haha(n+1); for(long long i = 1; i <= n; i++) { cin >> haha[i]; br[haha[i]]++; } sort(br.begin(),br.end()); long long l = 0,r = 0; for(long long i = 0; i < br.size(); i++) { if(br[i] > 0) { if(l > r) { swap(l,r); } long long c = n-l-br[i]; ans+=n*(n+1)/2-l*(l+1)/2-c*(c+1)/2; l+=br[i]; } } cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Correct | 10 ms | 2652 KB | Output is correct |
3 | Correct | 5 ms | 2652 KB | Output is correct |
4 | Correct | 4 ms | 2652 KB | Output is correct |
5 | Correct | 6 ms | 2652 KB | Output is correct |
6 | Correct | 10 ms | 2652 KB | Output is correct |
7 | Correct | 5 ms | 2652 KB | Output is correct |
8 | Correct | 5 ms | 2652 KB | Output is correct |
9 | Correct | 5 ms | 2652 KB | Output is correct |
10 | Correct | 6 ms | 2648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2652 KB | Output is correct |
2 | Correct | 5 ms | 2652 KB | Output is correct |
3 | Correct | 7 ms | 2652 KB | Output is correct |
4 | Correct | 9 ms | 3676 KB | Output is correct |
5 | Correct | 13 ms | 4700 KB | Output is correct |
6 | Correct | 19 ms | 5720 KB | Output is correct |
7 | Correct | 19 ms | 5724 KB | Output is correct |
8 | Correct | 19 ms | 5724 KB | Output is correct |
9 | Correct | 20 ms | 5640 KB | Output is correct |
10 | Correct | 21 ms | 5784 KB | Output is correct |
11 | Correct | 18 ms | 5652 KB | Output is correct |
12 | Correct | 21 ms | 5832 KB | Output is correct |
13 | Correct | 18 ms | 5660 KB | Output is correct |
14 | Correct | 15 ms | 5720 KB | Output is correct |
15 | Correct | 17 ms | 5720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2652 KB | Output is correct |
2 | Correct | 5 ms | 2652 KB | Output is correct |
3 | Correct | 7 ms | 2652 KB | Output is correct |
4 | Correct | 9 ms | 3676 KB | Output is correct |
5 | Correct | 13 ms | 4700 KB | Output is correct |
6 | Correct | 19 ms | 5720 KB | Output is correct |
7 | Correct | 19 ms | 5724 KB | Output is correct |
8 | Correct | 19 ms | 5724 KB | Output is correct |
9 | Correct | 20 ms | 5640 KB | Output is correct |
10 | Correct | 21 ms | 5784 KB | Output is correct |
11 | Correct | 18 ms | 5652 KB | Output is correct |
12 | Correct | 21 ms | 5832 KB | Output is correct |
13 | Correct | 18 ms | 5660 KB | Output is correct |
14 | Correct | 15 ms | 5720 KB | Output is correct |
15 | Correct | 17 ms | 5720 KB | Output is correct |
16 | Correct | 6 ms | 2652 KB | Output is correct |
17 | Correct | 8 ms | 2648 KB | Output is correct |
18 | Correct | 6 ms | 2908 KB | Output is correct |
19 | Correct | 12 ms | 3876 KB | Output is correct |
20 | Correct | 20 ms | 4912 KB | Output is correct |
21 | Correct | 19 ms | 5980 KB | Output is correct |
22 | Correct | 19 ms | 5724 KB | Output is correct |
23 | Correct | 17 ms | 5956 KB | Output is correct |
24 | Correct | 21 ms | 5768 KB | Output is correct |
25 | Correct | 21 ms | 5720 KB | Output is correct |
26 | Correct | 19 ms | 5724 KB | Output is correct |
27 | Correct | 22 ms | 5716 KB | Output is correct |
28 | Correct | 22 ms | 5788 KB | Output is correct |
29 | Correct | 18 ms | 5908 KB | Output is correct |
30 | Correct | 20 ms | 5724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2652 KB | Output is correct |
2 | Correct | 5 ms | 2652 KB | Output is correct |
3 | Correct | 7 ms | 2652 KB | Output is correct |
4 | Correct | 9 ms | 3676 KB | Output is correct |
5 | Correct | 13 ms | 4700 KB | Output is correct |
6 | Correct | 19 ms | 5720 KB | Output is correct |
7 | Correct | 19 ms | 5724 KB | Output is correct |
8 | Correct | 19 ms | 5724 KB | Output is correct |
9 | Correct | 20 ms | 5640 KB | Output is correct |
10 | Correct | 21 ms | 5784 KB | Output is correct |
11 | Correct | 18 ms | 5652 KB | Output is correct |
12 | Correct | 21 ms | 5832 KB | Output is correct |
13 | Correct | 18 ms | 5660 KB | Output is correct |
14 | Correct | 15 ms | 5720 KB | Output is correct |
15 | Correct | 17 ms | 5720 KB | Output is correct |
16 | Correct | 6 ms | 2652 KB | Output is correct |
17 | Correct | 8 ms | 2648 KB | Output is correct |
18 | Correct | 6 ms | 2908 KB | Output is correct |
19 | Correct | 12 ms | 3876 KB | Output is correct |
20 | Correct | 20 ms | 4912 KB | Output is correct |
21 | Correct | 19 ms | 5980 KB | Output is correct |
22 | Correct | 19 ms | 5724 KB | Output is correct |
23 | Correct | 17 ms | 5956 KB | Output is correct |
24 | Correct | 21 ms | 5768 KB | Output is correct |
25 | Correct | 21 ms | 5720 KB | Output is correct |
26 | Correct | 19 ms | 5724 KB | Output is correct |
27 | Correct | 22 ms | 5716 KB | Output is correct |
28 | Correct | 22 ms | 5788 KB | Output is correct |
29 | Correct | 18 ms | 5908 KB | Output is correct |
30 | Correct | 20 ms | 5724 KB | Output is correct |
31 | Correct | 6 ms | 2652 KB | Output is correct |
32 | Correct | 5 ms | 2652 KB | Output is correct |
33 | Correct | 9 ms | 2652 KB | Output is correct |
34 | Correct | 6 ms | 2908 KB | Output is correct |
35 | Correct | 6 ms | 2904 KB | Output is correct |
36 | Correct | 6 ms | 2904 KB | Output is correct |
37 | Correct | 7 ms | 3164 KB | Output is correct |
38 | Correct | 7 ms | 3404 KB | Output is correct |
39 | Correct | 19 ms | 3928 KB | Output is correct |
40 | Correct | 13 ms | 5012 KB | Output is correct |
41 | Correct | 33 ms | 6172 KB | Output is correct |
42 | Correct | 22 ms | 6308 KB | Output is correct |
43 | Correct | 18 ms | 6172 KB | Output is correct |
44 | Correct | 20 ms | 6232 KB | Output is correct |
45 | Correct | 18 ms | 6236 KB | Output is correct |
46 | Correct | 18 ms | 6236 KB | Output is correct |
47 | Correct | 18 ms | 6236 KB | Output is correct |
48 | Correct | 21 ms | 6236 KB | Output is correct |
49 | Correct | 33 ms | 6236 KB | Output is correct |
50 | Correct | 19 ms | 6236 KB | Output is correct |
51 | Correct | 21 ms | 6232 KB | Output is correct |
52 | Correct | 20 ms | 6236 KB | Output is correct |
53 | Correct | 37 ms | 6168 KB | Output is correct |
54 | Correct | 18 ms | 6296 KB | Output is correct |
55 | Correct | 21 ms | 6232 KB | Output is correct |
56 | Correct | 18 ms | 6304 KB | Output is correct |
57 | Correct | 18 ms | 6304 KB | Output is correct |
58 | Correct | 18 ms | 6300 KB | Output is correct |
59 | Correct | 33 ms | 6292 KB | Output is correct |
60 | Correct | 18 ms | 6236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Correct | 10 ms | 2652 KB | Output is correct |
3 | Correct | 5 ms | 2652 KB | Output is correct |
4 | Correct | 4 ms | 2652 KB | Output is correct |
5 | Correct | 6 ms | 2652 KB | Output is correct |
6 | Correct | 10 ms | 2652 KB | Output is correct |
7 | Correct | 5 ms | 2652 KB | Output is correct |
8 | Correct | 5 ms | 2652 KB | Output is correct |
9 | Correct | 5 ms | 2652 KB | Output is correct |
10 | Correct | 6 ms | 2648 KB | Output is correct |
11 | Correct | 5 ms | 2652 KB | Output is correct |
12 | Correct | 5 ms | 2652 KB | Output is correct |
13 | Correct | 7 ms | 2652 KB | Output is correct |
14 | Correct | 9 ms | 3676 KB | Output is correct |
15 | Correct | 13 ms | 4700 KB | Output is correct |
16 | Correct | 19 ms | 5720 KB | Output is correct |
17 | Correct | 19 ms | 5724 KB | Output is correct |
18 | Correct | 19 ms | 5724 KB | Output is correct |
19 | Correct | 20 ms | 5640 KB | Output is correct |
20 | Correct | 21 ms | 5784 KB | Output is correct |
21 | Correct | 18 ms | 5652 KB | Output is correct |
22 | Correct | 21 ms | 5832 KB | Output is correct |
23 | Correct | 18 ms | 5660 KB | Output is correct |
24 | Correct | 15 ms | 5720 KB | Output is correct |
25 | Correct | 17 ms | 5720 KB | Output is correct |
26 | Correct | 6 ms | 2652 KB | Output is correct |
27 | Correct | 8 ms | 2648 KB | Output is correct |
28 | Correct | 6 ms | 2908 KB | Output is correct |
29 | Correct | 12 ms | 3876 KB | Output is correct |
30 | Correct | 20 ms | 4912 KB | Output is correct |
31 | Correct | 19 ms | 5980 KB | Output is correct |
32 | Correct | 19 ms | 5724 KB | Output is correct |
33 | Correct | 17 ms | 5956 KB | Output is correct |
34 | Correct | 21 ms | 5768 KB | Output is correct |
35 | Correct | 21 ms | 5720 KB | Output is correct |
36 | Correct | 19 ms | 5724 KB | Output is correct |
37 | Correct | 22 ms | 5716 KB | Output is correct |
38 | Correct | 22 ms | 5788 KB | Output is correct |
39 | Correct | 18 ms | 5908 KB | Output is correct |
40 | Correct | 20 ms | 5724 KB | Output is correct |
41 | Correct | 6 ms | 2652 KB | Output is correct |
42 | Correct | 5 ms | 2652 KB | Output is correct |
43 | Correct | 9 ms | 2652 KB | Output is correct |
44 | Correct | 6 ms | 2908 KB | Output is correct |
45 | Correct | 6 ms | 2904 KB | Output is correct |
46 | Correct | 6 ms | 2904 KB | Output is correct |
47 | Correct | 7 ms | 3164 KB | Output is correct |
48 | Correct | 7 ms | 3404 KB | Output is correct |
49 | Correct | 19 ms | 3928 KB | Output is correct |
50 | Correct | 13 ms | 5012 KB | Output is correct |
51 | Correct | 33 ms | 6172 KB | Output is correct |
52 | Correct | 22 ms | 6308 KB | Output is correct |
53 | Correct | 18 ms | 6172 KB | Output is correct |
54 | Correct | 20 ms | 6232 KB | Output is correct |
55 | Correct | 18 ms | 6236 KB | Output is correct |
56 | Correct | 18 ms | 6236 KB | Output is correct |
57 | Correct | 18 ms | 6236 KB | Output is correct |
58 | Correct | 21 ms | 6236 KB | Output is correct |
59 | Correct | 33 ms | 6236 KB | Output is correct |
60 | Correct | 19 ms | 6236 KB | Output is correct |
61 | Correct | 21 ms | 6232 KB | Output is correct |
62 | Correct | 20 ms | 6236 KB | Output is correct |
63 | Correct | 37 ms | 6168 KB | Output is correct |
64 | Correct | 18 ms | 6296 KB | Output is correct |
65 | Correct | 21 ms | 6232 KB | Output is correct |
66 | Correct | 18 ms | 6304 KB | Output is correct |
67 | Correct | 18 ms | 6304 KB | Output is correct |
68 | Correct | 18 ms | 6300 KB | Output is correct |
69 | Correct | 33 ms | 6292 KB | Output is correct |
70 | Correct | 18 ms | 6236 KB | Output is correct |
71 | Correct | 9 ms | 3416 KB | Output is correct |
72 | Correct | 8 ms | 3416 KB | Output is correct |
73 | Correct | 8 ms | 3420 KB | Output is correct |
74 | Correct | 7 ms | 3428 KB | Output is correct |
75 | Correct | 8 ms | 3420 KB | Output is correct |
76 | Correct | 16 ms | 3852 KB | Output is correct |
77 | Correct | 11 ms | 3928 KB | Output is correct |
78 | Correct | 13 ms | 4108 KB | Output is correct |
79 | Correct | 11 ms | 3932 KB | Output is correct |
80 | Correct | 13 ms | 4064 KB | Output is correct |
81 | Correct | 15 ms | 5268 KB | Output is correct |
82 | Correct | 18 ms | 5208 KB | Output is correct |
83 | Correct | 28 ms | 5212 KB | Output is correct |
84 | Correct | 19 ms | 5392 KB | Output is correct |
85 | Correct | 14 ms | 5208 KB | Output is correct |
86 | Correct | 16 ms | 5212 KB | Output is correct |
87 | Correct | 15 ms | 5268 KB | Output is correct |
88 | Correct | 18 ms | 5208 KB | Output is correct |
89 | Correct | 17 ms | 5208 KB | Output is correct |
90 | Correct | 17 ms | 5212 KB | Output is correct |
91 | Correct | 23 ms | 6680 KB | Output is correct |
92 | Correct | 24 ms | 6744 KB | Output is correct |
93 | Correct | 23 ms | 6748 KB | Output is correct |
94 | Correct | 23 ms | 6748 KB | Output is correct |
95 | Correct | 23 ms | 6744 KB | Output is correct |
96 | Correct | 26 ms | 6796 KB | Output is correct |
97 | Correct | 28 ms | 7004 KB | Output is correct |
98 | Correct | 25 ms | 7000 KB | Output is correct |
99 | Correct | 26 ms | 7004 KB | Output is correct |
100 | Correct | 27 ms | 6996 KB | Output is correct |
101 | Correct | 28 ms | 7004 KB | Output is correct |
102 | Correct | 24 ms | 7004 KB | Output is correct |
103 | Correct | 29 ms | 6944 KB | Output is correct |
104 | Correct | 28 ms | 7004 KB | Output is correct |
105 | Correct | 27 ms | 6992 KB | Output is correct |
106 | Correct | 28 ms | 7004 KB | Output is correct |
107 | Correct | 25 ms | 7004 KB | Output is correct |
108 | Correct | 29 ms | 7004 KB | Output is correct |
109 | Correct | 25 ms | 7004 KB | Output is correct |
110 | Correct | 27 ms | 7068 KB | Output is correct |
111 | Correct | 25 ms | 7000 KB | Output is correct |
112 | Correct | 26 ms | 6996 KB | Output is correct |
113 | Correct | 28 ms | 7004 KB | Output is correct |
114 | Correct | 29 ms | 7004 KB | Output is correct |
115 | Correct | 31 ms | 7004 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Correct | 10 ms | 2652 KB | Output is correct |
3 | Correct | 5 ms | 2652 KB | Output is correct |
4 | Correct | 4 ms | 2652 KB | Output is correct |
5 | Correct | 6 ms | 2652 KB | Output is correct |
6 | Correct | 10 ms | 2652 KB | Output is correct |
7 | Correct | 5 ms | 2652 KB | Output is correct |
8 | Correct | 5 ms | 2652 KB | Output is correct |
9 | Correct | 5 ms | 2652 KB | Output is correct |
10 | Correct | 6 ms | 2648 KB | Output is correct |
11 | Correct | 5 ms | 2652 KB | Output is correct |
12 | Correct | 5 ms | 2652 KB | Output is correct |
13 | Correct | 7 ms | 2652 KB | Output is correct |
14 | Correct | 9 ms | 3676 KB | Output is correct |
15 | Correct | 13 ms | 4700 KB | Output is correct |
16 | Correct | 19 ms | 5720 KB | Output is correct |
17 | Correct | 19 ms | 5724 KB | Output is correct |
18 | Correct | 19 ms | 5724 KB | Output is correct |
19 | Correct | 20 ms | 5640 KB | Output is correct |
20 | Correct | 21 ms | 5784 KB | Output is correct |
21 | Correct | 18 ms | 5652 KB | Output is correct |
22 | Correct | 21 ms | 5832 KB | Output is correct |
23 | Correct | 18 ms | 5660 KB | Output is correct |
24 | Correct | 15 ms | 5720 KB | Output is correct |
25 | Correct | 17 ms | 5720 KB | Output is correct |
26 | Correct | 6 ms | 2652 KB | Output is correct |
27 | Correct | 8 ms | 2648 KB | Output is correct |
28 | Correct | 6 ms | 2908 KB | Output is correct |
29 | Correct | 12 ms | 3876 KB | Output is correct |
30 | Correct | 20 ms | 4912 KB | Output is correct |
31 | Correct | 19 ms | 5980 KB | Output is correct |
32 | Correct | 19 ms | 5724 KB | Output is correct |
33 | Correct | 17 ms | 5956 KB | Output is correct |
34 | Correct | 21 ms | 5768 KB | Output is correct |
35 | Correct | 21 ms | 5720 KB | Output is correct |
36 | Correct | 19 ms | 5724 KB | Output is correct |
37 | Correct | 22 ms | 5716 KB | Output is correct |
38 | Correct | 22 ms | 5788 KB | Output is correct |
39 | Correct | 18 ms | 5908 KB | Output is correct |
40 | Correct | 20 ms | 5724 KB | Output is correct |
41 | Correct | 6 ms | 2652 KB | Output is correct |
42 | Correct | 5 ms | 2652 KB | Output is correct |
43 | Correct | 9 ms | 2652 KB | Output is correct |
44 | Correct | 6 ms | 2908 KB | Output is correct |
45 | Correct | 6 ms | 2904 KB | Output is correct |
46 | Correct | 6 ms | 2904 KB | Output is correct |
47 | Correct | 7 ms | 3164 KB | Output is correct |
48 | Correct | 7 ms | 3404 KB | Output is correct |
49 | Correct | 19 ms | 3928 KB | Output is correct |
50 | Correct | 13 ms | 5012 KB | Output is correct |
51 | Correct | 33 ms | 6172 KB | Output is correct |
52 | Correct | 22 ms | 6308 KB | Output is correct |
53 | Correct | 18 ms | 6172 KB | Output is correct |
54 | Correct | 20 ms | 6232 KB | Output is correct |
55 | Correct | 18 ms | 6236 KB | Output is correct |
56 | Correct | 18 ms | 6236 KB | Output is correct |
57 | Correct | 18 ms | 6236 KB | Output is correct |
58 | Correct | 21 ms | 6236 KB | Output is correct |
59 | Correct | 33 ms | 6236 KB | Output is correct |
60 | Correct | 19 ms | 6236 KB | Output is correct |
61 | Correct | 21 ms | 6232 KB | Output is correct |
62 | Correct | 20 ms | 6236 KB | Output is correct |
63 | Correct | 37 ms | 6168 KB | Output is correct |
64 | Correct | 18 ms | 6296 KB | Output is correct |
65 | Correct | 21 ms | 6232 KB | Output is correct |
66 | Correct | 18 ms | 6304 KB | Output is correct |
67 | Correct | 18 ms | 6304 KB | Output is correct |
68 | Correct | 18 ms | 6300 KB | Output is correct |
69 | Correct | 33 ms | 6292 KB | Output is correct |
70 | Correct | 18 ms | 6236 KB | Output is correct |
71 | Correct | 9 ms | 3416 KB | Output is correct |
72 | Correct | 8 ms | 3416 KB | Output is correct |
73 | Correct | 8 ms | 3420 KB | Output is correct |
74 | Correct | 7 ms | 3428 KB | Output is correct |
75 | Correct | 8 ms | 3420 KB | Output is correct |
76 | Correct | 16 ms | 3852 KB | Output is correct |
77 | Correct | 11 ms | 3928 KB | Output is correct |
78 | Correct | 13 ms | 4108 KB | Output is correct |
79 | Correct | 11 ms | 3932 KB | Output is correct |
80 | Correct | 13 ms | 4064 KB | Output is correct |
81 | Correct | 15 ms | 5268 KB | Output is correct |
82 | Correct | 18 ms | 5208 KB | Output is correct |
83 | Correct | 28 ms | 5212 KB | Output is correct |
84 | Correct | 19 ms | 5392 KB | Output is correct |
85 | Correct | 14 ms | 5208 KB | Output is correct |
86 | Correct | 16 ms | 5212 KB | Output is correct |
87 | Correct | 15 ms | 5268 KB | Output is correct |
88 | Correct | 18 ms | 5208 KB | Output is correct |
89 | Correct | 17 ms | 5208 KB | Output is correct |
90 | Correct | 17 ms | 5212 KB | Output is correct |
91 | Correct | 23 ms | 6680 KB | Output is correct |
92 | Correct | 24 ms | 6744 KB | Output is correct |
93 | Correct | 23 ms | 6748 KB | Output is correct |
94 | Correct | 23 ms | 6748 KB | Output is correct |
95 | Correct | 23 ms | 6744 KB | Output is correct |
96 | Correct | 26 ms | 6796 KB | Output is correct |
97 | Correct | 28 ms | 7004 KB | Output is correct |
98 | Correct | 25 ms | 7000 KB | Output is correct |
99 | Correct | 26 ms | 7004 KB | Output is correct |
100 | Correct | 27 ms | 6996 KB | Output is correct |
101 | Correct | 28 ms | 7004 KB | Output is correct |
102 | Correct | 24 ms | 7004 KB | Output is correct |
103 | Correct | 29 ms | 6944 KB | Output is correct |
104 | Correct | 28 ms | 7004 KB | Output is correct |
105 | Correct | 27 ms | 6992 KB | Output is correct |
106 | Correct | 28 ms | 7004 KB | Output is correct |
107 | Correct | 25 ms | 7004 KB | Output is correct |
108 | Correct | 29 ms | 7004 KB | Output is correct |
109 | Correct | 25 ms | 7004 KB | Output is correct |
110 | Correct | 27 ms | 7068 KB | Output is correct |
111 | Correct | 25 ms | 7000 KB | Output is correct |
112 | Correct | 26 ms | 6996 KB | Output is correct |
113 | Correct | 28 ms | 7004 KB | Output is correct |
114 | Correct | 29 ms | 7004 KB | Output is correct |
115 | Correct | 31 ms | 7004 KB | Output is correct |
116 | Incorrect | 5 ms | 2908 KB | Output isn't correct |
117 | Halted | 0 ms | 0 KB | - |