답안 #659732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
659732 2022-11-19T08:05:44 Z fatemetmhr Diversity (CEOI21_diversity) C++17
64 / 100
37 ms 4040 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb     push_back
#define fi     first
#define se     second
#define all(x) x.begin(), x.end()
 
const int maxn5 = 4e5 + 10;
 
int cnt[maxn5];
vector <int> av, tmp[2];
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
 
    int n, q; cin >> n >> q;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        cnt[a]++;
    }
    sort(cnt, cnt + maxn5);
    int num = 0;
    for(int i = 0; i < maxn5; i++) if(cnt[i]){
        tmp[num].pb(cnt[i]);
        num ^= 1;
    }
    for(auto u : tmp[0])
        av.pb(u);
    reverse(all(tmp[1]));
    for(auto u : tmp[1])
        av.pb(u);
    ll ans = 0;
    int a; cin >> a >> a;
    ll ind = 1;
    for(auto u : av){
        //cout << u << endl;
        int v = u;
        ans += ind * (n + 1 - ind);
        ind++; v--;
        while(v--){
            ans += (n + 1 - ind);
            ind++;
        }
    }
    cout << ans << endl;
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1884 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 6 ms 1888 KB Output is correct
4 Correct 6 ms 1892 KB Output is correct
5 Correct 5 ms 1876 KB Output is correct
6 Correct 5 ms 1876 KB Output is correct
7 Correct 5 ms 1884 KB Output is correct
8 Correct 6 ms 1876 KB Output is correct
9 Correct 5 ms 1876 KB Output is correct
10 Correct 5 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 8 ms 2004 KB Output is correct
4 Correct 9 ms 1876 KB Output is correct
5 Correct 14 ms 1876 KB Output is correct
6 Correct 22 ms 1876 KB Output is correct
7 Correct 18 ms 1876 KB Output is correct
8 Correct 18 ms 1876 KB Output is correct
9 Correct 19 ms 1860 KB Output is correct
10 Correct 19 ms 1860 KB Output is correct
11 Correct 20 ms 1864 KB Output is correct
12 Correct 20 ms 1864 KB Output is correct
13 Correct 19 ms 1864 KB Output is correct
14 Correct 19 ms 1864 KB Output is correct
15 Correct 19 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 8 ms 2004 KB Output is correct
4 Correct 9 ms 1876 KB Output is correct
5 Correct 14 ms 1876 KB Output is correct
6 Correct 22 ms 1876 KB Output is correct
7 Correct 18 ms 1876 KB Output is correct
8 Correct 18 ms 1876 KB Output is correct
9 Correct 19 ms 1860 KB Output is correct
10 Correct 19 ms 1860 KB Output is correct
11 Correct 20 ms 1864 KB Output is correct
12 Correct 20 ms 1864 KB Output is correct
13 Correct 19 ms 1864 KB Output is correct
14 Correct 19 ms 1864 KB Output is correct
15 Correct 19 ms 1876 KB Output is correct
16 Correct 5 ms 1876 KB Output is correct
17 Correct 5 ms 1888 KB Output is correct
18 Correct 6 ms 1876 KB Output is correct
19 Correct 10 ms 1888 KB Output is correct
20 Correct 15 ms 1888 KB Output is correct
21 Correct 22 ms 1868 KB Output is correct
22 Correct 21 ms 1876 KB Output is correct
23 Correct 22 ms 1868 KB Output is correct
24 Correct 24 ms 1876 KB Output is correct
25 Correct 20 ms 1876 KB Output is correct
26 Correct 21 ms 1860 KB Output is correct
27 Correct 21 ms 1876 KB Output is correct
28 Correct 21 ms 1864 KB Output is correct
29 Correct 21 ms 1868 KB Output is correct
30 Correct 20 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 8 ms 2004 KB Output is correct
4 Correct 9 ms 1876 KB Output is correct
5 Correct 14 ms 1876 KB Output is correct
6 Correct 22 ms 1876 KB Output is correct
7 Correct 18 ms 1876 KB Output is correct
8 Correct 18 ms 1876 KB Output is correct
9 Correct 19 ms 1860 KB Output is correct
10 Correct 19 ms 1860 KB Output is correct
11 Correct 20 ms 1864 KB Output is correct
12 Correct 20 ms 1864 KB Output is correct
13 Correct 19 ms 1864 KB Output is correct
14 Correct 19 ms 1864 KB Output is correct
15 Correct 19 ms 1876 KB Output is correct
16 Correct 5 ms 1876 KB Output is correct
17 Correct 5 ms 1888 KB Output is correct
18 Correct 6 ms 1876 KB Output is correct
19 Correct 10 ms 1888 KB Output is correct
20 Correct 15 ms 1888 KB Output is correct
21 Correct 22 ms 1868 KB Output is correct
22 Correct 21 ms 1876 KB Output is correct
23 Correct 22 ms 1868 KB Output is correct
24 Correct 24 ms 1876 KB Output is correct
25 Correct 20 ms 1876 KB Output is correct
26 Correct 21 ms 1860 KB Output is correct
27 Correct 21 ms 1876 KB Output is correct
28 Correct 21 ms 1864 KB Output is correct
29 Correct 21 ms 1868 KB Output is correct
30 Correct 20 ms 1876 KB Output is correct
31 Correct 6 ms 1876 KB Output is correct
32 Correct 5 ms 1876 KB Output is correct
33 Correct 5 ms 1876 KB Output is correct
34 Correct 6 ms 1876 KB Output is correct
35 Correct 6 ms 1876 KB Output is correct
36 Correct 6 ms 1888 KB Output is correct
37 Correct 8 ms 1876 KB Output is correct
38 Correct 8 ms 1876 KB Output is correct
39 Correct 11 ms 1876 KB Output is correct
40 Correct 16 ms 1868 KB Output is correct
41 Correct 22 ms 1876 KB Output is correct
42 Correct 21 ms 1872 KB Output is correct
43 Correct 22 ms 1868 KB Output is correct
44 Correct 23 ms 1864 KB Output is correct
45 Correct 23 ms 1868 KB Output is correct
46 Correct 22 ms 1876 KB Output is correct
47 Correct 22 ms 1876 KB Output is correct
48 Correct 22 ms 1876 KB Output is correct
49 Correct 25 ms 1864 KB Output is correct
50 Correct 22 ms 1876 KB Output is correct
51 Correct 21 ms 1876 KB Output is correct
52 Correct 22 ms 1876 KB Output is correct
53 Correct 24 ms 1888 KB Output is correct
54 Correct 21 ms 1864 KB Output is correct
55 Correct 22 ms 1868 KB Output is correct
56 Correct 21 ms 1876 KB Output is correct
57 Correct 21 ms 1876 KB Output is correct
58 Correct 22 ms 1868 KB Output is correct
59 Correct 22 ms 1868 KB Output is correct
60 Correct 22 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1884 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 6 ms 1888 KB Output is correct
4 Correct 6 ms 1892 KB Output is correct
5 Correct 5 ms 1876 KB Output is correct
6 Correct 5 ms 1876 KB Output is correct
7 Correct 5 ms 1884 KB Output is correct
8 Correct 6 ms 1876 KB Output is correct
9 Correct 5 ms 1876 KB Output is correct
10 Correct 5 ms 1876 KB Output is correct
11 Correct 5 ms 1876 KB Output is correct
12 Correct 5 ms 1876 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 1876 KB Output is correct
15 Correct 14 ms 1876 KB Output is correct
16 Correct 22 ms 1876 KB Output is correct
17 Correct 18 ms 1876 KB Output is correct
18 Correct 18 ms 1876 KB Output is correct
19 Correct 19 ms 1860 KB Output is correct
20 Correct 19 ms 1860 KB Output is correct
21 Correct 20 ms 1864 KB Output is correct
22 Correct 20 ms 1864 KB Output is correct
23 Correct 19 ms 1864 KB Output is correct
24 Correct 19 ms 1864 KB Output is correct
25 Correct 19 ms 1876 KB Output is correct
26 Correct 5 ms 1876 KB Output is correct
27 Correct 5 ms 1888 KB Output is correct
28 Correct 6 ms 1876 KB Output is correct
29 Correct 10 ms 1888 KB Output is correct
30 Correct 15 ms 1888 KB Output is correct
31 Correct 22 ms 1868 KB Output is correct
32 Correct 21 ms 1876 KB Output is correct
33 Correct 22 ms 1868 KB Output is correct
34 Correct 24 ms 1876 KB Output is correct
35 Correct 20 ms 1876 KB Output is correct
36 Correct 21 ms 1860 KB Output is correct
37 Correct 21 ms 1876 KB Output is correct
38 Correct 21 ms 1864 KB Output is correct
39 Correct 21 ms 1868 KB Output is correct
40 Correct 20 ms 1876 KB Output is correct
41 Correct 6 ms 1876 KB Output is correct
42 Correct 5 ms 1876 KB Output is correct
43 Correct 5 ms 1876 KB Output is correct
44 Correct 6 ms 1876 KB Output is correct
45 Correct 6 ms 1876 KB Output is correct
46 Correct 6 ms 1888 KB Output is correct
47 Correct 8 ms 1876 KB Output is correct
48 Correct 8 ms 1876 KB Output is correct
49 Correct 11 ms 1876 KB Output is correct
50 Correct 16 ms 1868 KB Output is correct
51 Correct 22 ms 1876 KB Output is correct
52 Correct 21 ms 1872 KB Output is correct
53 Correct 22 ms 1868 KB Output is correct
54 Correct 23 ms 1864 KB Output is correct
55 Correct 23 ms 1868 KB Output is correct
56 Correct 22 ms 1876 KB Output is correct
57 Correct 22 ms 1876 KB Output is correct
58 Correct 22 ms 1876 KB Output is correct
59 Correct 25 ms 1864 KB Output is correct
60 Correct 22 ms 1876 KB Output is correct
61 Correct 21 ms 1876 KB Output is correct
62 Correct 22 ms 1876 KB Output is correct
63 Correct 24 ms 1888 KB Output is correct
64 Correct 21 ms 1864 KB Output is correct
65 Correct 22 ms 1868 KB Output is correct
66 Correct 21 ms 1876 KB Output is correct
67 Correct 21 ms 1876 KB Output is correct
68 Correct 22 ms 1868 KB Output is correct
69 Correct 22 ms 1868 KB Output is correct
70 Correct 22 ms 1876 KB Output is correct
71 Correct 8 ms 1892 KB Output is correct
72 Correct 9 ms 1876 KB Output is correct
73 Correct 10 ms 1876 KB Output is correct
74 Correct 8 ms 1876 KB Output is correct
75 Correct 9 ms 1884 KB Output is correct
76 Correct 12 ms 1952 KB Output is correct
77 Correct 12 ms 1876 KB Output is correct
78 Correct 13 ms 1988 KB Output is correct
79 Correct 11 ms 1876 KB Output is correct
80 Correct 12 ms 1884 KB Output is correct
81 Correct 17 ms 2028 KB Output is correct
82 Correct 22 ms 2024 KB Output is correct
83 Correct 18 ms 2032 KB Output is correct
84 Correct 19 ms 2020 KB Output is correct
85 Correct 20 ms 2036 KB Output is correct
86 Correct 24 ms 2140 KB Output is correct
87 Correct 20 ms 2132 KB Output is correct
88 Correct 19 ms 2192 KB Output is correct
89 Correct 20 ms 2196 KB Output is correct
90 Correct 20 ms 2200 KB Output is correct
91 Correct 28 ms 3012 KB Output is correct
92 Correct 28 ms 3008 KB Output is correct
93 Correct 28 ms 3020 KB Output is correct
94 Correct 28 ms 3012 KB Output is correct
95 Correct 31 ms 3016 KB Output is correct
96 Correct 31 ms 3788 KB Output is correct
97 Correct 32 ms 3784 KB Output is correct
98 Correct 32 ms 3764 KB Output is correct
99 Correct 33 ms 3724 KB Output is correct
100 Correct 34 ms 3772 KB Output is correct
101 Correct 31 ms 3780 KB Output is correct
102 Correct 31 ms 3776 KB Output is correct
103 Correct 32 ms 3768 KB Output is correct
104 Correct 32 ms 3772 KB Output is correct
105 Correct 32 ms 3772 KB Output is correct
106 Correct 32 ms 3980 KB Output is correct
107 Correct 32 ms 4028 KB Output is correct
108 Correct 32 ms 3968 KB Output is correct
109 Correct 37 ms 4020 KB Output is correct
110 Correct 32 ms 3984 KB Output is correct
111 Correct 33 ms 4032 KB Output is correct
112 Correct 31 ms 3976 KB Output is correct
113 Correct 32 ms 3996 KB Output is correct
114 Correct 32 ms 3980 KB Output is correct
115 Correct 32 ms 4040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1884 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 6 ms 1888 KB Output is correct
4 Correct 6 ms 1892 KB Output is correct
5 Correct 5 ms 1876 KB Output is correct
6 Correct 5 ms 1876 KB Output is correct
7 Correct 5 ms 1884 KB Output is correct
8 Correct 6 ms 1876 KB Output is correct
9 Correct 5 ms 1876 KB Output is correct
10 Correct 5 ms 1876 KB Output is correct
11 Correct 5 ms 1876 KB Output is correct
12 Correct 5 ms 1876 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 1876 KB Output is correct
15 Correct 14 ms 1876 KB Output is correct
16 Correct 22 ms 1876 KB Output is correct
17 Correct 18 ms 1876 KB Output is correct
18 Correct 18 ms 1876 KB Output is correct
19 Correct 19 ms 1860 KB Output is correct
20 Correct 19 ms 1860 KB Output is correct
21 Correct 20 ms 1864 KB Output is correct
22 Correct 20 ms 1864 KB Output is correct
23 Correct 19 ms 1864 KB Output is correct
24 Correct 19 ms 1864 KB Output is correct
25 Correct 19 ms 1876 KB Output is correct
26 Correct 5 ms 1876 KB Output is correct
27 Correct 5 ms 1888 KB Output is correct
28 Correct 6 ms 1876 KB Output is correct
29 Correct 10 ms 1888 KB Output is correct
30 Correct 15 ms 1888 KB Output is correct
31 Correct 22 ms 1868 KB Output is correct
32 Correct 21 ms 1876 KB Output is correct
33 Correct 22 ms 1868 KB Output is correct
34 Correct 24 ms 1876 KB Output is correct
35 Correct 20 ms 1876 KB Output is correct
36 Correct 21 ms 1860 KB Output is correct
37 Correct 21 ms 1876 KB Output is correct
38 Correct 21 ms 1864 KB Output is correct
39 Correct 21 ms 1868 KB Output is correct
40 Correct 20 ms 1876 KB Output is correct
41 Correct 6 ms 1876 KB Output is correct
42 Correct 5 ms 1876 KB Output is correct
43 Correct 5 ms 1876 KB Output is correct
44 Correct 6 ms 1876 KB Output is correct
45 Correct 6 ms 1876 KB Output is correct
46 Correct 6 ms 1888 KB Output is correct
47 Correct 8 ms 1876 KB Output is correct
48 Correct 8 ms 1876 KB Output is correct
49 Correct 11 ms 1876 KB Output is correct
50 Correct 16 ms 1868 KB Output is correct
51 Correct 22 ms 1876 KB Output is correct
52 Correct 21 ms 1872 KB Output is correct
53 Correct 22 ms 1868 KB Output is correct
54 Correct 23 ms 1864 KB Output is correct
55 Correct 23 ms 1868 KB Output is correct
56 Correct 22 ms 1876 KB Output is correct
57 Correct 22 ms 1876 KB Output is correct
58 Correct 22 ms 1876 KB Output is correct
59 Correct 25 ms 1864 KB Output is correct
60 Correct 22 ms 1876 KB Output is correct
61 Correct 21 ms 1876 KB Output is correct
62 Correct 22 ms 1876 KB Output is correct
63 Correct 24 ms 1888 KB Output is correct
64 Correct 21 ms 1864 KB Output is correct
65 Correct 22 ms 1868 KB Output is correct
66 Correct 21 ms 1876 KB Output is correct
67 Correct 21 ms 1876 KB Output is correct
68 Correct 22 ms 1868 KB Output is correct
69 Correct 22 ms 1868 KB Output is correct
70 Correct 22 ms 1876 KB Output is correct
71 Correct 8 ms 1892 KB Output is correct
72 Correct 9 ms 1876 KB Output is correct
73 Correct 10 ms 1876 KB Output is correct
74 Correct 8 ms 1876 KB Output is correct
75 Correct 9 ms 1884 KB Output is correct
76 Correct 12 ms 1952 KB Output is correct
77 Correct 12 ms 1876 KB Output is correct
78 Correct 13 ms 1988 KB Output is correct
79 Correct 11 ms 1876 KB Output is correct
80 Correct 12 ms 1884 KB Output is correct
81 Correct 17 ms 2028 KB Output is correct
82 Correct 22 ms 2024 KB Output is correct
83 Correct 18 ms 2032 KB Output is correct
84 Correct 19 ms 2020 KB Output is correct
85 Correct 20 ms 2036 KB Output is correct
86 Correct 24 ms 2140 KB Output is correct
87 Correct 20 ms 2132 KB Output is correct
88 Correct 19 ms 2192 KB Output is correct
89 Correct 20 ms 2196 KB Output is correct
90 Correct 20 ms 2200 KB Output is correct
91 Correct 28 ms 3012 KB Output is correct
92 Correct 28 ms 3008 KB Output is correct
93 Correct 28 ms 3020 KB Output is correct
94 Correct 28 ms 3012 KB Output is correct
95 Correct 31 ms 3016 KB Output is correct
96 Correct 31 ms 3788 KB Output is correct
97 Correct 32 ms 3784 KB Output is correct
98 Correct 32 ms 3764 KB Output is correct
99 Correct 33 ms 3724 KB Output is correct
100 Correct 34 ms 3772 KB Output is correct
101 Correct 31 ms 3780 KB Output is correct
102 Correct 31 ms 3776 KB Output is correct
103 Correct 32 ms 3768 KB Output is correct
104 Correct 32 ms 3772 KB Output is correct
105 Correct 32 ms 3772 KB Output is correct
106 Correct 32 ms 3980 KB Output is correct
107 Correct 32 ms 4028 KB Output is correct
108 Correct 32 ms 3968 KB Output is correct
109 Correct 37 ms 4020 KB Output is correct
110 Correct 32 ms 3984 KB Output is correct
111 Correct 33 ms 4032 KB Output is correct
112 Correct 31 ms 3976 KB Output is correct
113 Correct 32 ms 3996 KB Output is correct
114 Correct 32 ms 3980 KB Output is correct
115 Correct 32 ms 4040 KB Output is correct
116 Incorrect 6 ms 1876 KB Output isn't correct
117 Halted 0 ms 0 KB -