Submission #659736

# Submission time Handle Problem Language Result Execution time Memory
659736 2022-11-19T08:09:58 Z fatemetmhr Diversity (CEOI21_diversity) C++17
64 / 100
47 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(int i = 1; i <= n; i++)
        ans += (n + 1 - i);
    for(auto u : av){
        //cout << u << endl;
        ans += (ind - 1) * (n + 1 - ind);
        ind += u;
    }
    cout << ans << endl;
 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 7 ms 1880 KB Output is correct
4 Correct 6 ms 1876 KB Output is correct
5 Correct 5 ms 1884 KB Output is correct
6 Correct 6 ms 1880 KB Output is correct
7 Correct 5 ms 1884 KB Output is correct
8 Correct 5 ms 1876 KB Output is correct
9 Correct 8 ms 1876 KB Output is correct
10 Correct 5 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1888 KB Output is correct
2 Correct 5 ms 1880 KB Output is correct
3 Correct 7 ms 1876 KB Output is correct
4 Correct 12 ms 1876 KB Output is correct
5 Correct 15 ms 1864 KB Output is correct
6 Correct 22 ms 1888 KB Output is correct
7 Correct 20 ms 1856 KB Output is correct
8 Correct 21 ms 1876 KB Output is correct
9 Correct 20 ms 1856 KB Output is correct
10 Correct 24 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 24 ms 1856 KB Output is correct
14 Correct 21 ms 1864 KB Output is correct
15 Correct 19 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1888 KB Output is correct
2 Correct 5 ms 1880 KB Output is correct
3 Correct 7 ms 1876 KB Output is correct
4 Correct 12 ms 1876 KB Output is correct
5 Correct 15 ms 1864 KB Output is correct
6 Correct 22 ms 1888 KB Output is correct
7 Correct 20 ms 1856 KB Output is correct
8 Correct 21 ms 1876 KB Output is correct
9 Correct 20 ms 1856 KB Output is correct
10 Correct 24 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 24 ms 1856 KB Output is correct
14 Correct 21 ms 1864 KB Output is correct
15 Correct 19 ms 1876 KB Output is correct
16 Correct 6 ms 1876 KB Output is correct
17 Correct 6 ms 1876 KB Output is correct
18 Correct 6 ms 1876 KB Output is correct
19 Correct 12 ms 1868 KB Output is correct
20 Correct 18 ms 1876 KB Output is correct
21 Correct 23 ms 1860 KB Output is correct
22 Correct 21 ms 1876 KB Output is correct
23 Correct 24 ms 1864 KB Output is correct
24 Correct 22 ms 1856 KB Output is correct
25 Correct 23 ms 1864 KB Output is correct
26 Correct 21 ms 1876 KB Output is correct
27 Correct 25 ms 1864 KB Output is correct
28 Correct 22 ms 1864 KB Output is correct
29 Correct 25 ms 1872 KB Output is correct
30 Correct 21 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1888 KB Output is correct
2 Correct 5 ms 1880 KB Output is correct
3 Correct 7 ms 1876 KB Output is correct
4 Correct 12 ms 1876 KB Output is correct
5 Correct 15 ms 1864 KB Output is correct
6 Correct 22 ms 1888 KB Output is correct
7 Correct 20 ms 1856 KB Output is correct
8 Correct 21 ms 1876 KB Output is correct
9 Correct 20 ms 1856 KB Output is correct
10 Correct 24 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 24 ms 1856 KB Output is correct
14 Correct 21 ms 1864 KB Output is correct
15 Correct 19 ms 1876 KB Output is correct
16 Correct 6 ms 1876 KB Output is correct
17 Correct 6 ms 1876 KB Output is correct
18 Correct 6 ms 1876 KB Output is correct
19 Correct 12 ms 1868 KB Output is correct
20 Correct 18 ms 1876 KB Output is correct
21 Correct 23 ms 1860 KB Output is correct
22 Correct 21 ms 1876 KB Output is correct
23 Correct 24 ms 1864 KB Output is correct
24 Correct 22 ms 1856 KB Output is correct
25 Correct 23 ms 1864 KB Output is correct
26 Correct 21 ms 1876 KB Output is correct
27 Correct 25 ms 1864 KB Output is correct
28 Correct 22 ms 1864 KB Output is correct
29 Correct 25 ms 1872 KB Output is correct
30 Correct 21 ms 1876 KB Output is correct
31 Correct 6 ms 1876 KB Output is correct
32 Correct 6 ms 1876 KB Output is correct
33 Correct 6 ms 1876 KB Output is correct
34 Correct 7 ms 1876 KB Output is correct
35 Correct 8 ms 1876 KB Output is correct
36 Correct 6 ms 1888 KB Output is correct
37 Correct 10 ms 1876 KB Output is correct
38 Correct 8 ms 1876 KB Output is correct
39 Correct 15 ms 1896 KB Output is correct
40 Correct 19 ms 1872 KB Output is correct
41 Correct 22 ms 1868 KB Output is correct
42 Correct 22 ms 1864 KB Output is correct
43 Correct 22 ms 1864 KB Output is correct
44 Correct 22 ms 1864 KB Output is correct
45 Correct 22 ms 1880 KB Output is correct
46 Correct 22 ms 1876 KB Output is correct
47 Correct 23 ms 1876 KB Output is correct
48 Correct 22 ms 1864 KB Output is correct
49 Correct 23 ms 1868 KB Output is correct
50 Correct 22 ms 1876 KB Output is correct
51 Correct 26 ms 1868 KB Output is correct
52 Correct 23 ms 1872 KB Output is correct
53 Correct 22 ms 1868 KB Output is correct
54 Correct 23 ms 1876 KB Output is correct
55 Correct 24 ms 1844 KB Output is correct
56 Correct 22 ms 1868 KB Output is correct
57 Correct 22 ms 1872 KB Output is correct
58 Correct 22 ms 1864 KB Output is correct
59 Correct 22 ms 1868 KB Output is correct
60 Correct 26 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 7 ms 1880 KB Output is correct
4 Correct 6 ms 1876 KB Output is correct
5 Correct 5 ms 1884 KB Output is correct
6 Correct 6 ms 1880 KB Output is correct
7 Correct 5 ms 1884 KB Output is correct
8 Correct 5 ms 1876 KB Output is correct
9 Correct 8 ms 1876 KB Output is correct
10 Correct 5 ms 1876 KB Output is correct
11 Correct 6 ms 1888 KB Output is correct
12 Correct 5 ms 1880 KB Output is correct
13 Correct 7 ms 1876 KB Output is correct
14 Correct 12 ms 1876 KB Output is correct
15 Correct 15 ms 1864 KB Output is correct
16 Correct 22 ms 1888 KB Output is correct
17 Correct 20 ms 1856 KB Output is correct
18 Correct 21 ms 1876 KB Output is correct
19 Correct 20 ms 1856 KB Output is correct
20 Correct 24 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 24 ms 1856 KB Output is correct
24 Correct 21 ms 1864 KB Output is correct
25 Correct 19 ms 1876 KB Output is correct
26 Correct 6 ms 1876 KB Output is correct
27 Correct 6 ms 1876 KB Output is correct
28 Correct 6 ms 1876 KB Output is correct
29 Correct 12 ms 1868 KB Output is correct
30 Correct 18 ms 1876 KB Output is correct
31 Correct 23 ms 1860 KB Output is correct
32 Correct 21 ms 1876 KB Output is correct
33 Correct 24 ms 1864 KB Output is correct
34 Correct 22 ms 1856 KB Output is correct
35 Correct 23 ms 1864 KB Output is correct
36 Correct 21 ms 1876 KB Output is correct
37 Correct 25 ms 1864 KB Output is correct
38 Correct 22 ms 1864 KB Output is correct
39 Correct 25 ms 1872 KB Output is correct
40 Correct 21 ms 1876 KB Output is correct
41 Correct 6 ms 1876 KB Output is correct
42 Correct 6 ms 1876 KB Output is correct
43 Correct 6 ms 1876 KB Output is correct
44 Correct 7 ms 1876 KB Output is correct
45 Correct 8 ms 1876 KB Output is correct
46 Correct 6 ms 1888 KB Output is correct
47 Correct 10 ms 1876 KB Output is correct
48 Correct 8 ms 1876 KB Output is correct
49 Correct 15 ms 1896 KB Output is correct
50 Correct 19 ms 1872 KB Output is correct
51 Correct 22 ms 1868 KB Output is correct
52 Correct 22 ms 1864 KB Output is correct
53 Correct 22 ms 1864 KB Output is correct
54 Correct 22 ms 1864 KB Output is correct
55 Correct 22 ms 1880 KB Output is correct
56 Correct 22 ms 1876 KB Output is correct
57 Correct 23 ms 1876 KB Output is correct
58 Correct 22 ms 1864 KB Output is correct
59 Correct 23 ms 1868 KB Output is correct
60 Correct 22 ms 1876 KB Output is correct
61 Correct 26 ms 1868 KB Output is correct
62 Correct 23 ms 1872 KB Output is correct
63 Correct 22 ms 1868 KB Output is correct
64 Correct 23 ms 1876 KB Output is correct
65 Correct 24 ms 1844 KB Output is correct
66 Correct 22 ms 1868 KB Output is correct
67 Correct 22 ms 1872 KB Output is correct
68 Correct 22 ms 1864 KB Output is correct
69 Correct 22 ms 1868 KB Output is correct
70 Correct 26 ms 1868 KB Output is correct
71 Correct 9 ms 1876 KB Output is correct
72 Correct 8 ms 1876 KB Output is correct
73 Correct 10 ms 1888 KB Output is correct
74 Correct 8 ms 1868 KB Output is correct
75 Correct 9 ms 1876 KB Output is correct
76 Correct 11 ms 1876 KB Output is correct
77 Correct 14 ms 1880 KB Output is correct
78 Correct 11 ms 1892 KB Output is correct
79 Correct 12 ms 1876 KB Output is correct
80 Correct 12 ms 1880 KB Output is correct
81 Correct 19 ms 2032 KB Output is correct
82 Correct 18 ms 2004 KB Output is correct
83 Correct 19 ms 2004 KB Output is correct
84 Correct 19 ms 2032 KB Output is correct
85 Correct 18 ms 2004 KB Output is correct
86 Correct 24 ms 2200 KB Output is correct
87 Correct 20 ms 2196 KB Output is correct
88 Correct 22 ms 2188 KB Output is correct
89 Correct 20 ms 2072 KB Output is correct
90 Correct 20 ms 2200 KB Output is correct
91 Correct 28 ms 3016 KB Output is correct
92 Correct 28 ms 3008 KB Output is correct
93 Correct 28 ms 3020 KB Output is correct
94 Correct 31 ms 3028 KB Output is correct
95 Correct 29 ms 3016 KB Output is correct
96 Correct 33 ms 3776 KB Output is correct
97 Correct 34 ms 3760 KB Output is correct
98 Correct 47 ms 3772 KB Output is correct
99 Correct 41 ms 3764 KB Output is correct
100 Correct 33 ms 3776 KB Output is correct
101 Correct 34 ms 3784 KB Output is correct
102 Correct 32 ms 3772 KB Output is correct
103 Correct 33 ms 3776 KB Output is correct
104 Correct 33 ms 3776 KB Output is correct
105 Correct 34 ms 3784 KB Output is correct
106 Correct 32 ms 3972 KB Output is correct
107 Correct 33 ms 4040 KB Output is correct
108 Correct 36 ms 3972 KB Output is correct
109 Correct 36 ms 3964 KB Output is correct
110 Correct 33 ms 3968 KB Output is correct
111 Correct 33 ms 4040 KB Output is correct
112 Correct 32 ms 4040 KB Output is correct
113 Correct 32 ms 3976 KB Output is correct
114 Correct 32 ms 3916 KB Output is correct
115 Correct 32 ms 3968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1876 KB Output is correct
2 Correct 5 ms 1876 KB Output is correct
3 Correct 7 ms 1880 KB Output is correct
4 Correct 6 ms 1876 KB Output is correct
5 Correct 5 ms 1884 KB Output is correct
6 Correct 6 ms 1880 KB Output is correct
7 Correct 5 ms 1884 KB Output is correct
8 Correct 5 ms 1876 KB Output is correct
9 Correct 8 ms 1876 KB Output is correct
10 Correct 5 ms 1876 KB Output is correct
11 Correct 6 ms 1888 KB Output is correct
12 Correct 5 ms 1880 KB Output is correct
13 Correct 7 ms 1876 KB Output is correct
14 Correct 12 ms 1876 KB Output is correct
15 Correct 15 ms 1864 KB Output is correct
16 Correct 22 ms 1888 KB Output is correct
17 Correct 20 ms 1856 KB Output is correct
18 Correct 21 ms 1876 KB Output is correct
19 Correct 20 ms 1856 KB Output is correct
20 Correct 24 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 24 ms 1856 KB Output is correct
24 Correct 21 ms 1864 KB Output is correct
25 Correct 19 ms 1876 KB Output is correct
26 Correct 6 ms 1876 KB Output is correct
27 Correct 6 ms 1876 KB Output is correct
28 Correct 6 ms 1876 KB Output is correct
29 Correct 12 ms 1868 KB Output is correct
30 Correct 18 ms 1876 KB Output is correct
31 Correct 23 ms 1860 KB Output is correct
32 Correct 21 ms 1876 KB Output is correct
33 Correct 24 ms 1864 KB Output is correct
34 Correct 22 ms 1856 KB Output is correct
35 Correct 23 ms 1864 KB Output is correct
36 Correct 21 ms 1876 KB Output is correct
37 Correct 25 ms 1864 KB Output is correct
38 Correct 22 ms 1864 KB Output is correct
39 Correct 25 ms 1872 KB Output is correct
40 Correct 21 ms 1876 KB Output is correct
41 Correct 6 ms 1876 KB Output is correct
42 Correct 6 ms 1876 KB Output is correct
43 Correct 6 ms 1876 KB Output is correct
44 Correct 7 ms 1876 KB Output is correct
45 Correct 8 ms 1876 KB Output is correct
46 Correct 6 ms 1888 KB Output is correct
47 Correct 10 ms 1876 KB Output is correct
48 Correct 8 ms 1876 KB Output is correct
49 Correct 15 ms 1896 KB Output is correct
50 Correct 19 ms 1872 KB Output is correct
51 Correct 22 ms 1868 KB Output is correct
52 Correct 22 ms 1864 KB Output is correct
53 Correct 22 ms 1864 KB Output is correct
54 Correct 22 ms 1864 KB Output is correct
55 Correct 22 ms 1880 KB Output is correct
56 Correct 22 ms 1876 KB Output is correct
57 Correct 23 ms 1876 KB Output is correct
58 Correct 22 ms 1864 KB Output is correct
59 Correct 23 ms 1868 KB Output is correct
60 Correct 22 ms 1876 KB Output is correct
61 Correct 26 ms 1868 KB Output is correct
62 Correct 23 ms 1872 KB Output is correct
63 Correct 22 ms 1868 KB Output is correct
64 Correct 23 ms 1876 KB Output is correct
65 Correct 24 ms 1844 KB Output is correct
66 Correct 22 ms 1868 KB Output is correct
67 Correct 22 ms 1872 KB Output is correct
68 Correct 22 ms 1864 KB Output is correct
69 Correct 22 ms 1868 KB Output is correct
70 Correct 26 ms 1868 KB Output is correct
71 Correct 9 ms 1876 KB Output is correct
72 Correct 8 ms 1876 KB Output is correct
73 Correct 10 ms 1888 KB Output is correct
74 Correct 8 ms 1868 KB Output is correct
75 Correct 9 ms 1876 KB Output is correct
76 Correct 11 ms 1876 KB Output is correct
77 Correct 14 ms 1880 KB Output is correct
78 Correct 11 ms 1892 KB Output is correct
79 Correct 12 ms 1876 KB Output is correct
80 Correct 12 ms 1880 KB Output is correct
81 Correct 19 ms 2032 KB Output is correct
82 Correct 18 ms 2004 KB Output is correct
83 Correct 19 ms 2004 KB Output is correct
84 Correct 19 ms 2032 KB Output is correct
85 Correct 18 ms 2004 KB Output is correct
86 Correct 24 ms 2200 KB Output is correct
87 Correct 20 ms 2196 KB Output is correct
88 Correct 22 ms 2188 KB Output is correct
89 Correct 20 ms 2072 KB Output is correct
90 Correct 20 ms 2200 KB Output is correct
91 Correct 28 ms 3016 KB Output is correct
92 Correct 28 ms 3008 KB Output is correct
93 Correct 28 ms 3020 KB Output is correct
94 Correct 31 ms 3028 KB Output is correct
95 Correct 29 ms 3016 KB Output is correct
96 Correct 33 ms 3776 KB Output is correct
97 Correct 34 ms 3760 KB Output is correct
98 Correct 47 ms 3772 KB Output is correct
99 Correct 41 ms 3764 KB Output is correct
100 Correct 33 ms 3776 KB Output is correct
101 Correct 34 ms 3784 KB Output is correct
102 Correct 32 ms 3772 KB Output is correct
103 Correct 33 ms 3776 KB Output is correct
104 Correct 33 ms 3776 KB Output is correct
105 Correct 34 ms 3784 KB Output is correct
106 Correct 32 ms 3972 KB Output is correct
107 Correct 33 ms 4040 KB Output is correct
108 Correct 36 ms 3972 KB Output is correct
109 Correct 36 ms 3964 KB Output is correct
110 Correct 33 ms 3968 KB Output is correct
111 Correct 33 ms 4040 KB Output is correct
112 Correct 32 ms 4040 KB Output is correct
113 Correct 32 ms 3976 KB Output is correct
114 Correct 32 ms 3916 KB Output is correct
115 Correct 32 ms 3968 KB Output is correct
116 Incorrect 6 ms 1876 KB Output isn't correct
117 Halted 0 ms 0 KB -