# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
737951 | 2023-05-08T02:59:02 Z | guagua0407 | Diversity (CEOI21_diversity) | C++17 | 90 ms | 9588 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define all(x) x.begin(),x.end() int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,q; cin>>n>>q; ll a[n]; for(ll i=0;i<n;i++){ cin>>a[i]; } sort(a,a+n); vector<ll> vec; ll cnt=1; ll cur=a[0]; for(ll i=1;i<n;i++){ if(a[i]==cur){ cnt++; } else{ vec.push_back(cnt); cnt=1; cur=a[i]; } } vec.push_back(cnt); sort(vec.begin(),vec.end()); vector<ll> vec2; for(int i=0;i<vec.size();i+=2){ vec2.push_back(vec[i]); } for(int i=((vec.size()-1)%2==0?vec.size()-2:vec.size()-1);i>=1;i-=2){ vec2.push_back(vec[i]); } ll ans=0; ll now=0; for(auto v:vec2){ ans+=(now+v)*(n-now); ans-=(v)*(v-1)/2; now+=v; } cout<<ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 320 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 11 ms | 1292 KB | Output is correct |
5 | Correct | 19 ms | 2252 KB | Output is correct |
6 | Correct | 25 ms | 3288 KB | Output is correct |
7 | Correct | 26 ms | 3164 KB | Output is correct |
8 | Correct | 24 ms | 3168 KB | Output is correct |
9 | Correct | 31 ms | 3284 KB | Output is correct |
10 | Correct | 24 ms | 3284 KB | Output is correct |
11 | Correct | 24 ms | 3296 KB | Output is correct |
12 | Correct | 27 ms | 3284 KB | Output is correct |
13 | Correct | 26 ms | 3284 KB | Output is correct |
14 | Correct | 38 ms | 3284 KB | Output is correct |
15 | Correct | 30 ms | 3284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 11 ms | 1292 KB | Output is correct |
5 | Correct | 19 ms | 2252 KB | Output is correct |
6 | Correct | 25 ms | 3288 KB | Output is correct |
7 | Correct | 26 ms | 3164 KB | Output is correct |
8 | Correct | 24 ms | 3168 KB | Output is correct |
9 | Correct | 31 ms | 3284 KB | Output is correct |
10 | Correct | 24 ms | 3284 KB | Output is correct |
11 | Correct | 24 ms | 3296 KB | Output is correct |
12 | Correct | 27 ms | 3284 KB | Output is correct |
13 | Correct | 26 ms | 3284 KB | Output is correct |
14 | Correct | 38 ms | 3284 KB | Output is correct |
15 | Correct | 30 ms | 3284 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 9 ms | 1352 KB | Output is correct |
20 | Correct | 20 ms | 2376 KB | Output is correct |
21 | Correct | 29 ms | 3468 KB | Output is correct |
22 | Correct | 30 ms | 3412 KB | Output is correct |
23 | Correct | 27 ms | 3412 KB | Output is correct |
24 | Correct | 27 ms | 3456 KB | Output is correct |
25 | Correct | 28 ms | 3412 KB | Output is correct |
26 | Correct | 28 ms | 3420 KB | Output is correct |
27 | Correct | 28 ms | 3412 KB | Output is correct |
28 | Correct | 32 ms | 3380 KB | Output is correct |
29 | Correct | 36 ms | 3288 KB | Output is correct |
30 | Correct | 30 ms | 3412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 416 KB | Output is correct |
4 | Correct | 11 ms | 1292 KB | Output is correct |
5 | Correct | 19 ms | 2252 KB | Output is correct |
6 | Correct | 25 ms | 3288 KB | Output is correct |
7 | Correct | 26 ms | 3164 KB | Output is correct |
8 | Correct | 24 ms | 3168 KB | Output is correct |
9 | Correct | 31 ms | 3284 KB | Output is correct |
10 | Correct | 24 ms | 3284 KB | Output is correct |
11 | Correct | 24 ms | 3296 KB | Output is correct |
12 | Correct | 27 ms | 3284 KB | Output is correct |
13 | Correct | 26 ms | 3284 KB | Output is correct |
14 | Correct | 38 ms | 3284 KB | Output is correct |
15 | Correct | 30 ms | 3284 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 9 ms | 1352 KB | Output is correct |
20 | Correct | 20 ms | 2376 KB | Output is correct |
21 | Correct | 29 ms | 3468 KB | Output is correct |
22 | Correct | 30 ms | 3412 KB | Output is correct |
23 | Correct | 27 ms | 3412 KB | Output is correct |
24 | Correct | 27 ms | 3456 KB | Output is correct |
25 | Correct | 28 ms | 3412 KB | Output is correct |
26 | Correct | 28 ms | 3420 KB | Output is correct |
27 | Correct | 28 ms | 3412 KB | Output is correct |
28 | Correct | 32 ms | 3380 KB | Output is correct |
29 | Correct | 36 ms | 3288 KB | Output is correct |
30 | Correct | 30 ms | 3412 KB | Output is correct |
31 | Correct | 1 ms | 372 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 324 KB | Output is correct |
34 | Correct | 2 ms | 340 KB | Output is correct |
35 | Correct | 2 ms | 340 KB | Output is correct |
36 | Correct | 2 ms | 340 KB | Output is correct |
37 | Correct | 9 ms | 840 KB | Output is correct |
38 | Correct | 6 ms | 844 KB | Output is correct |
39 | Correct | 12 ms | 1492 KB | Output is correct |
40 | Correct | 24 ms | 2632 KB | Output is correct |
41 | Correct | 38 ms | 3800 KB | Output is correct |
42 | Correct | 40 ms | 3800 KB | Output is correct |
43 | Correct | 47 ms | 3780 KB | Output is correct |
44 | Correct | 39 ms | 3792 KB | Output is correct |
45 | Correct | 37 ms | 3784 KB | Output is correct |
46 | Correct | 50 ms | 3780 KB | Output is correct |
47 | Correct | 34 ms | 3780 KB | Output is correct |
48 | Correct | 52 ms | 3788 KB | Output is correct |
49 | Correct | 38 ms | 3796 KB | Output is correct |
50 | Correct | 37 ms | 3784 KB | Output is correct |
51 | Correct | 37 ms | 3796 KB | Output is correct |
52 | Correct | 35 ms | 3784 KB | Output is correct |
53 | Correct | 38 ms | 3796 KB | Output is correct |
54 | Correct | 34 ms | 3796 KB | Output is correct |
55 | Correct | 36 ms | 3796 KB | Output is correct |
56 | Correct | 35 ms | 3784 KB | Output is correct |
57 | Correct | 35 ms | 3788 KB | Output is correct |
58 | Correct | 33 ms | 3792 KB | Output is correct |
59 | Correct | 35 ms | 3788 KB | Output is correct |
60 | Correct | 36 ms | 3788 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 320 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 | 1 ms | 212 KB | Output is correct |
13 | Correct | 2 ms | 416 KB | Output is correct |
14 | Correct | 11 ms | 1292 KB | Output is correct |
15 | Correct | 19 ms | 2252 KB | Output is correct |
16 | Correct | 25 ms | 3288 KB | Output is correct |
17 | Correct | 26 ms | 3164 KB | Output is correct |
18 | Correct | 24 ms | 3168 KB | Output is correct |
19 | Correct | 31 ms | 3284 KB | Output is correct |
20 | Correct | 24 ms | 3284 KB | Output is correct |
21 | Correct | 24 ms | 3296 KB | Output is correct |
22 | Correct | 27 ms | 3284 KB | Output is correct |
23 | Correct | 26 ms | 3284 KB | Output is correct |
24 | Correct | 38 ms | 3284 KB | Output is correct |
25 | Correct | 30 ms | 3284 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 9 ms | 1352 KB | Output is correct |
30 | Correct | 20 ms | 2376 KB | Output is correct |
31 | Correct | 29 ms | 3468 KB | Output is correct |
32 | Correct | 30 ms | 3412 KB | Output is correct |
33 | Correct | 27 ms | 3412 KB | Output is correct |
34 | Correct | 27 ms | 3456 KB | Output is correct |
35 | Correct | 28 ms | 3412 KB | Output is correct |
36 | Correct | 28 ms | 3420 KB | Output is correct |
37 | Correct | 28 ms | 3412 KB | Output is correct |
38 | Correct | 32 ms | 3380 KB | Output is correct |
39 | Correct | 36 ms | 3288 KB | Output is correct |
40 | Correct | 30 ms | 3412 KB | Output is correct |
41 | Correct | 1 ms | 372 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 324 KB | Output is correct |
44 | Correct | 2 ms | 340 KB | Output is correct |
45 | Correct | 2 ms | 340 KB | Output is correct |
46 | Correct | 2 ms | 340 KB | Output is correct |
47 | Correct | 9 ms | 840 KB | Output is correct |
48 | Correct | 6 ms | 844 KB | Output is correct |
49 | Correct | 12 ms | 1492 KB | Output is correct |
50 | Correct | 24 ms | 2632 KB | Output is correct |
51 | Correct | 38 ms | 3800 KB | Output is correct |
52 | Correct | 40 ms | 3800 KB | Output is correct |
53 | Correct | 47 ms | 3780 KB | Output is correct |
54 | Correct | 39 ms | 3792 KB | Output is correct |
55 | Correct | 37 ms | 3784 KB | Output is correct |
56 | Correct | 50 ms | 3780 KB | Output is correct |
57 | Correct | 34 ms | 3780 KB | Output is correct |
58 | Correct | 52 ms | 3788 KB | Output is correct |
59 | Correct | 38 ms | 3796 KB | Output is correct |
60 | Correct | 37 ms | 3784 KB | Output is correct |
61 | Correct | 37 ms | 3796 KB | Output is correct |
62 | Correct | 35 ms | 3784 KB | Output is correct |
63 | Correct | 38 ms | 3796 KB | Output is correct |
64 | Correct | 34 ms | 3796 KB | Output is correct |
65 | Correct | 36 ms | 3796 KB | Output is correct |
66 | Correct | 35 ms | 3784 KB | Output is correct |
67 | Correct | 35 ms | 3788 KB | Output is correct |
68 | Correct | 33 ms | 3792 KB | Output is correct |
69 | Correct | 35 ms | 3788 KB | Output is correct |
70 | Correct | 36 ms | 3788 KB | Output is correct |
71 | Correct | 10 ms | 928 KB | Output is correct |
72 | Correct | 11 ms | 956 KB | Output is correct |
73 | Correct | 10 ms | 924 KB | Output is correct |
74 | Correct | 8 ms | 852 KB | Output is correct |
75 | Correct | 8 ms | 852 KB | Output is correct |
76 | Correct | 14 ms | 1692 KB | Output is correct |
77 | Correct | 21 ms | 1612 KB | Output is correct |
78 | Correct | 15 ms | 1620 KB | Output is correct |
79 | Correct | 13 ms | 1620 KB | Output is correct |
80 | Correct | 16 ms | 1680 KB | Output is correct |
81 | Correct | 29 ms | 3024 KB | Output is correct |
82 | Correct | 29 ms | 3012 KB | Output is correct |
83 | Correct | 28 ms | 3020 KB | Output is correct |
84 | Correct | 28 ms | 3012 KB | Output is correct |
85 | Correct | 28 ms | 3096 KB | Output is correct |
86 | Correct | 29 ms | 3400 KB | Output is correct |
87 | Correct | 43 ms | 3408 KB | Output is correct |
88 | Correct | 35 ms | 3440 KB | Output is correct |
89 | Correct | 32 ms | 3408 KB | Output is correct |
90 | Correct | 31 ms | 3460 KB | Output is correct |
91 | Correct | 51 ms | 6676 KB | Output is correct |
92 | Correct | 53 ms | 6608 KB | Output is correct |
93 | Correct | 58 ms | 6600 KB | Output is correct |
94 | Correct | 53 ms | 6608 KB | Output is correct |
95 | Correct | 60 ms | 6716 KB | Output is correct |
96 | Correct | 57 ms | 9140 KB | Output is correct |
97 | Correct | 53 ms | 9140 KB | Output is correct |
98 | Correct | 57 ms | 9164 KB | Output is correct |
99 | Correct | 68 ms | 9136 KB | Output is correct |
100 | Correct | 68 ms | 9164 KB | Output is correct |
101 | Correct | 78 ms | 9164 KB | Output is correct |
102 | Correct | 57 ms | 9140 KB | Output is correct |
103 | Correct | 61 ms | 9156 KB | Output is correct |
104 | Correct | 67 ms | 9136 KB | Output is correct |
105 | Correct | 57 ms | 9140 KB | Output is correct |
106 | Correct | 56 ms | 9552 KB | Output is correct |
107 | Correct | 66 ms | 9536 KB | Output is correct |
108 | Correct | 71 ms | 9556 KB | Output is correct |
109 | Correct | 68 ms | 9532 KB | Output is correct |
110 | Correct | 63 ms | 9540 KB | Output is correct |
111 | Correct | 64 ms | 9556 KB | Output is correct |
112 | Correct | 61 ms | 9560 KB | Output is correct |
113 | Correct | 90 ms | 9556 KB | Output is correct |
114 | Correct | 62 ms | 9544 KB | Output is correct |
115 | Correct | 61 ms | 9588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 320 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 | 1 ms | 212 KB | Output is correct |
13 | Correct | 2 ms | 416 KB | Output is correct |
14 | Correct | 11 ms | 1292 KB | Output is correct |
15 | Correct | 19 ms | 2252 KB | Output is correct |
16 | Correct | 25 ms | 3288 KB | Output is correct |
17 | Correct | 26 ms | 3164 KB | Output is correct |
18 | Correct | 24 ms | 3168 KB | Output is correct |
19 | Correct | 31 ms | 3284 KB | Output is correct |
20 | Correct | 24 ms | 3284 KB | Output is correct |
21 | Correct | 24 ms | 3296 KB | Output is correct |
22 | Correct | 27 ms | 3284 KB | Output is correct |
23 | Correct | 26 ms | 3284 KB | Output is correct |
24 | Correct | 38 ms | 3284 KB | Output is correct |
25 | Correct | 30 ms | 3284 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 9 ms | 1352 KB | Output is correct |
30 | Correct | 20 ms | 2376 KB | Output is correct |
31 | Correct | 29 ms | 3468 KB | Output is correct |
32 | Correct | 30 ms | 3412 KB | Output is correct |
33 | Correct | 27 ms | 3412 KB | Output is correct |
34 | Correct | 27 ms | 3456 KB | Output is correct |
35 | Correct | 28 ms | 3412 KB | Output is correct |
36 | Correct | 28 ms | 3420 KB | Output is correct |
37 | Correct | 28 ms | 3412 KB | Output is correct |
38 | Correct | 32 ms | 3380 KB | Output is correct |
39 | Correct | 36 ms | 3288 KB | Output is correct |
40 | Correct | 30 ms | 3412 KB | Output is correct |
41 | Correct | 1 ms | 372 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 324 KB | Output is correct |
44 | Correct | 2 ms | 340 KB | Output is correct |
45 | Correct | 2 ms | 340 KB | Output is correct |
46 | Correct | 2 ms | 340 KB | Output is correct |
47 | Correct | 9 ms | 840 KB | Output is correct |
48 | Correct | 6 ms | 844 KB | Output is correct |
49 | Correct | 12 ms | 1492 KB | Output is correct |
50 | Correct | 24 ms | 2632 KB | Output is correct |
51 | Correct | 38 ms | 3800 KB | Output is correct |
52 | Correct | 40 ms | 3800 KB | Output is correct |
53 | Correct | 47 ms | 3780 KB | Output is correct |
54 | Correct | 39 ms | 3792 KB | Output is correct |
55 | Correct | 37 ms | 3784 KB | Output is correct |
56 | Correct | 50 ms | 3780 KB | Output is correct |
57 | Correct | 34 ms | 3780 KB | Output is correct |
58 | Correct | 52 ms | 3788 KB | Output is correct |
59 | Correct | 38 ms | 3796 KB | Output is correct |
60 | Correct | 37 ms | 3784 KB | Output is correct |
61 | Correct | 37 ms | 3796 KB | Output is correct |
62 | Correct | 35 ms | 3784 KB | Output is correct |
63 | Correct | 38 ms | 3796 KB | Output is correct |
64 | Correct | 34 ms | 3796 KB | Output is correct |
65 | Correct | 36 ms | 3796 KB | Output is correct |
66 | Correct | 35 ms | 3784 KB | Output is correct |
67 | Correct | 35 ms | 3788 KB | Output is correct |
68 | Correct | 33 ms | 3792 KB | Output is correct |
69 | Correct | 35 ms | 3788 KB | Output is correct |
70 | Correct | 36 ms | 3788 KB | Output is correct |
71 | Correct | 10 ms | 928 KB | Output is correct |
72 | Correct | 11 ms | 956 KB | Output is correct |
73 | Correct | 10 ms | 924 KB | Output is correct |
74 | Correct | 8 ms | 852 KB | Output is correct |
75 | Correct | 8 ms | 852 KB | Output is correct |
76 | Correct | 14 ms | 1692 KB | Output is correct |
77 | Correct | 21 ms | 1612 KB | Output is correct |
78 | Correct | 15 ms | 1620 KB | Output is correct |
79 | Correct | 13 ms | 1620 KB | Output is correct |
80 | Correct | 16 ms | 1680 KB | Output is correct |
81 | Correct | 29 ms | 3024 KB | Output is correct |
82 | Correct | 29 ms | 3012 KB | Output is correct |
83 | Correct | 28 ms | 3020 KB | Output is correct |
84 | Correct | 28 ms | 3012 KB | Output is correct |
85 | Correct | 28 ms | 3096 KB | Output is correct |
86 | Correct | 29 ms | 3400 KB | Output is correct |
87 | Correct | 43 ms | 3408 KB | Output is correct |
88 | Correct | 35 ms | 3440 KB | Output is correct |
89 | Correct | 32 ms | 3408 KB | Output is correct |
90 | Correct | 31 ms | 3460 KB | Output is correct |
91 | Correct | 51 ms | 6676 KB | Output is correct |
92 | Correct | 53 ms | 6608 KB | Output is correct |
93 | Correct | 58 ms | 6600 KB | Output is correct |
94 | Correct | 53 ms | 6608 KB | Output is correct |
95 | Correct | 60 ms | 6716 KB | Output is correct |
96 | Correct | 57 ms | 9140 KB | Output is correct |
97 | Correct | 53 ms | 9140 KB | Output is correct |
98 | Correct | 57 ms | 9164 KB | Output is correct |
99 | Correct | 68 ms | 9136 KB | Output is correct |
100 | Correct | 68 ms | 9164 KB | Output is correct |
101 | Correct | 78 ms | 9164 KB | Output is correct |
102 | Correct | 57 ms | 9140 KB | Output is correct |
103 | Correct | 61 ms | 9156 KB | Output is correct |
104 | Correct | 67 ms | 9136 KB | Output is correct |
105 | Correct | 57 ms | 9140 KB | Output is correct |
106 | Correct | 56 ms | 9552 KB | Output is correct |
107 | Correct | 66 ms | 9536 KB | Output is correct |
108 | Correct | 71 ms | 9556 KB | Output is correct |
109 | Correct | 68 ms | 9532 KB | Output is correct |
110 | Correct | 63 ms | 9540 KB | Output is correct |
111 | Correct | 64 ms | 9556 KB | Output is correct |
112 | Correct | 61 ms | 9560 KB | Output is correct |
113 | Correct | 90 ms | 9556 KB | Output is correct |
114 | Correct | 62 ms | 9544 KB | Output is correct |
115 | Correct | 61 ms | 9588 KB | Output is correct |
116 | Incorrect | 2 ms | 468 KB | Output isn't correct |
117 | Halted | 0 ms | 0 KB | - |