Submission #620802

# Submission time Handle Problem Language Result Execution time Memory
620802 2022-08-03T09:25:26 Z berr Diversity (CEOI21_diversity) C++17
64 / 100
47 ms 7800 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    vector<int> a(300005, 0);
    int n, q; cin>>n>>q;

    for(int i=0; i<n; i++)
    {
        int x; cin>>x;
        a[x]++;
    }

    sort(a.begin(), a.end());
    int ans=0;
    vector<int> b, c;
    for(int i=0; i<a.size(); i++)
    {
        if(a[i]>0)
        {
            if(i%2) b.push_back(a[i]);
            else c.push_back(a[i]);
        }
    }
    int l, r; cin>>l>>r;


    reverse(c.begin(), c.end());
    for(auto i: c) b.push_back(i);

    int sum=0, all=0;
    for(int i=0; i<b.size(); i++)
    {
        sum+=all;
        ans+=sum*b[i]+(b[i]*(b[i]+1))/2;
        all+=b[i];
        sum+=b[i];
    }

    cout<<ans;
}

Compilation message

diversity.cpp: In function 'int32_t main()':
diversity.cpp:21:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0; i<a.size(); i++)
      |                  ~^~~~~~~~~
diversity.cpp:36:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0; i<b.size(); i++)
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2644 KB Output is correct
2 Correct 6 ms 2644 KB Output is correct
3 Correct 6 ms 2644 KB Output is correct
4 Correct 6 ms 2644 KB Output is correct
5 Correct 6 ms 2644 KB Output is correct
6 Correct 6 ms 2644 KB Output is correct
7 Correct 6 ms 2644 KB Output is correct
8 Correct 6 ms 2644 KB Output is correct
9 Correct 6 ms 2644 KB Output is correct
10 Correct 6 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2644 KB Output is correct
2 Correct 5 ms 2644 KB Output is correct
3 Correct 7 ms 2644 KB Output is correct
4 Correct 9 ms 2772 KB Output is correct
5 Correct 15 ms 3028 KB Output is correct
6 Correct 20 ms 3304 KB Output is correct
7 Correct 19 ms 3284 KB Output is correct
8 Correct 21 ms 3284 KB Output is correct
9 Correct 19 ms 3300 KB Output is correct
10 Correct 19 ms 3304 KB Output is correct
11 Correct 23 ms 3284 KB Output is correct
12 Correct 30 ms 3308 KB Output is correct
13 Correct 23 ms 3300 KB Output is correct
14 Correct 22 ms 3284 KB Output is correct
15 Correct 21 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2644 KB Output is correct
2 Correct 5 ms 2644 KB Output is correct
3 Correct 7 ms 2644 KB Output is correct
4 Correct 9 ms 2772 KB Output is correct
5 Correct 15 ms 3028 KB Output is correct
6 Correct 20 ms 3304 KB Output is correct
7 Correct 19 ms 3284 KB Output is correct
8 Correct 21 ms 3284 KB Output is correct
9 Correct 19 ms 3300 KB Output is correct
10 Correct 19 ms 3304 KB Output is correct
11 Correct 23 ms 3284 KB Output is correct
12 Correct 30 ms 3308 KB Output is correct
13 Correct 23 ms 3300 KB Output is correct
14 Correct 22 ms 3284 KB Output is correct
15 Correct 21 ms 3204 KB Output is correct
16 Correct 5 ms 2644 KB Output is correct
17 Correct 5 ms 2644 KB Output is correct
18 Correct 6 ms 2644 KB Output is correct
19 Correct 12 ms 2952 KB Output is correct
20 Correct 19 ms 3204 KB Output is correct
21 Correct 20 ms 3412 KB Output is correct
22 Correct 27 ms 3420 KB Output is correct
23 Correct 21 ms 3412 KB Output is correct
24 Correct 20 ms 3412 KB Output is correct
25 Correct 23 ms 3412 KB Output is correct
26 Correct 24 ms 3328 KB Output is correct
27 Correct 22 ms 3432 KB Output is correct
28 Correct 21 ms 3304 KB Output is correct
29 Correct 20 ms 3412 KB Output is correct
30 Correct 21 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2644 KB Output is correct
2 Correct 5 ms 2644 KB Output is correct
3 Correct 7 ms 2644 KB Output is correct
4 Correct 9 ms 2772 KB Output is correct
5 Correct 15 ms 3028 KB Output is correct
6 Correct 20 ms 3304 KB Output is correct
7 Correct 19 ms 3284 KB Output is correct
8 Correct 21 ms 3284 KB Output is correct
9 Correct 19 ms 3300 KB Output is correct
10 Correct 19 ms 3304 KB Output is correct
11 Correct 23 ms 3284 KB Output is correct
12 Correct 30 ms 3308 KB Output is correct
13 Correct 23 ms 3300 KB Output is correct
14 Correct 22 ms 3284 KB Output is correct
15 Correct 21 ms 3204 KB Output is correct
16 Correct 5 ms 2644 KB Output is correct
17 Correct 5 ms 2644 KB Output is correct
18 Correct 6 ms 2644 KB Output is correct
19 Correct 12 ms 2952 KB Output is correct
20 Correct 19 ms 3204 KB Output is correct
21 Correct 20 ms 3412 KB Output is correct
22 Correct 27 ms 3420 KB Output is correct
23 Correct 21 ms 3412 KB Output is correct
24 Correct 20 ms 3412 KB Output is correct
25 Correct 23 ms 3412 KB Output is correct
26 Correct 24 ms 3328 KB Output is correct
27 Correct 22 ms 3432 KB Output is correct
28 Correct 21 ms 3304 KB Output is correct
29 Correct 20 ms 3412 KB Output is correct
30 Correct 21 ms 3432 KB Output is correct
31 Correct 6 ms 2680 KB Output is correct
32 Correct 6 ms 2680 KB Output is correct
33 Correct 6 ms 2680 KB Output is correct
34 Correct 6 ms 2644 KB Output is correct
35 Correct 6 ms 2700 KB Output is correct
36 Correct 6 ms 2696 KB Output is correct
37 Correct 8 ms 2772 KB Output is correct
38 Correct 9 ms 2876 KB Output is correct
39 Correct 12 ms 3044 KB Output is correct
40 Correct 22 ms 3432 KB Output is correct
41 Correct 27 ms 3812 KB Output is correct
42 Correct 31 ms 3708 KB Output is correct
43 Correct 27 ms 3796 KB Output is correct
44 Correct 25 ms 3824 KB Output is correct
45 Correct 23 ms 3812 KB Output is correct
46 Correct 23 ms 3796 KB Output is correct
47 Correct 22 ms 3796 KB Output is correct
48 Correct 29 ms 3792 KB Output is correct
49 Correct 26 ms 3788 KB Output is correct
50 Correct 23 ms 3796 KB Output is correct
51 Correct 29 ms 3808 KB Output is correct
52 Correct 27 ms 3812 KB Output is correct
53 Correct 23 ms 3708 KB Output is correct
54 Correct 22 ms 3820 KB Output is correct
55 Correct 23 ms 3808 KB Output is correct
56 Correct 26 ms 3796 KB Output is correct
57 Correct 22 ms 3816 KB Output is correct
58 Correct 23 ms 3792 KB Output is correct
59 Correct 24 ms 3796 KB Output is correct
60 Correct 23 ms 3816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2644 KB Output is correct
2 Correct 6 ms 2644 KB Output is correct
3 Correct 6 ms 2644 KB Output is correct
4 Correct 6 ms 2644 KB Output is correct
5 Correct 6 ms 2644 KB Output is correct
6 Correct 6 ms 2644 KB Output is correct
7 Correct 6 ms 2644 KB Output is correct
8 Correct 6 ms 2644 KB Output is correct
9 Correct 6 ms 2644 KB Output is correct
10 Correct 6 ms 2644 KB Output is correct
11 Correct 6 ms 2644 KB Output is correct
12 Correct 5 ms 2644 KB Output is correct
13 Correct 7 ms 2644 KB Output is correct
14 Correct 9 ms 2772 KB Output is correct
15 Correct 15 ms 3028 KB Output is correct
16 Correct 20 ms 3304 KB Output is correct
17 Correct 19 ms 3284 KB Output is correct
18 Correct 21 ms 3284 KB Output is correct
19 Correct 19 ms 3300 KB Output is correct
20 Correct 19 ms 3304 KB Output is correct
21 Correct 23 ms 3284 KB Output is correct
22 Correct 30 ms 3308 KB Output is correct
23 Correct 23 ms 3300 KB Output is correct
24 Correct 22 ms 3284 KB Output is correct
25 Correct 21 ms 3204 KB Output is correct
26 Correct 5 ms 2644 KB Output is correct
27 Correct 5 ms 2644 KB Output is correct
28 Correct 6 ms 2644 KB Output is correct
29 Correct 12 ms 2952 KB Output is correct
30 Correct 19 ms 3204 KB Output is correct
31 Correct 20 ms 3412 KB Output is correct
32 Correct 27 ms 3420 KB Output is correct
33 Correct 21 ms 3412 KB Output is correct
34 Correct 20 ms 3412 KB Output is correct
35 Correct 23 ms 3412 KB Output is correct
36 Correct 24 ms 3328 KB Output is correct
37 Correct 22 ms 3432 KB Output is correct
38 Correct 21 ms 3304 KB Output is correct
39 Correct 20 ms 3412 KB Output is correct
40 Correct 21 ms 3432 KB Output is correct
41 Correct 6 ms 2680 KB Output is correct
42 Correct 6 ms 2680 KB Output is correct
43 Correct 6 ms 2680 KB Output is correct
44 Correct 6 ms 2644 KB Output is correct
45 Correct 6 ms 2700 KB Output is correct
46 Correct 6 ms 2696 KB Output is correct
47 Correct 8 ms 2772 KB Output is correct
48 Correct 9 ms 2876 KB Output is correct
49 Correct 12 ms 3044 KB Output is correct
50 Correct 22 ms 3432 KB Output is correct
51 Correct 27 ms 3812 KB Output is correct
52 Correct 31 ms 3708 KB Output is correct
53 Correct 27 ms 3796 KB Output is correct
54 Correct 25 ms 3824 KB Output is correct
55 Correct 23 ms 3812 KB Output is correct
56 Correct 23 ms 3796 KB Output is correct
57 Correct 22 ms 3796 KB Output is correct
58 Correct 29 ms 3792 KB Output is correct
59 Correct 26 ms 3788 KB Output is correct
60 Correct 23 ms 3796 KB Output is correct
61 Correct 29 ms 3808 KB Output is correct
62 Correct 27 ms 3812 KB Output is correct
63 Correct 23 ms 3708 KB Output is correct
64 Correct 22 ms 3820 KB Output is correct
65 Correct 23 ms 3808 KB Output is correct
66 Correct 26 ms 3796 KB Output is correct
67 Correct 22 ms 3816 KB Output is correct
68 Correct 23 ms 3792 KB Output is correct
69 Correct 24 ms 3796 KB Output is correct
70 Correct 23 ms 3816 KB Output is correct
71 Correct 9 ms 2900 KB Output is correct
72 Correct 9 ms 2900 KB Output is correct
73 Correct 10 ms 2900 KB Output is correct
74 Correct 9 ms 2824 KB Output is correct
75 Correct 9 ms 2900 KB Output is correct
76 Correct 13 ms 3156 KB Output is correct
77 Correct 12 ms 3220 KB Output is correct
78 Correct 12 ms 3276 KB Output is correct
79 Correct 12 ms 3176 KB Output is correct
80 Correct 13 ms 3280 KB Output is correct
81 Correct 24 ms 3880 KB Output is correct
82 Correct 21 ms 3884 KB Output is correct
83 Correct 30 ms 3884 KB Output is correct
84 Correct 21 ms 3892 KB Output is correct
85 Correct 19 ms 3884 KB Output is correct
86 Correct 20 ms 4192 KB Output is correct
87 Correct 20 ms 4200 KB Output is correct
88 Correct 20 ms 4124 KB Output is correct
89 Correct 20 ms 4120 KB Output is correct
90 Correct 23 ms 4192 KB Output is correct
91 Correct 39 ms 5960 KB Output is correct
92 Correct 44 ms 5912 KB Output is correct
93 Correct 36 ms 5996 KB Output is correct
94 Correct 34 ms 5976 KB Output is correct
95 Correct 29 ms 5956 KB Output is correct
96 Correct 38 ms 7596 KB Output is correct
97 Correct 34 ms 7484 KB Output is correct
98 Correct 43 ms 7504 KB Output is correct
99 Correct 33 ms 7500 KB Output is correct
100 Correct 34 ms 7496 KB Output is correct
101 Correct 33 ms 7596 KB Output is correct
102 Correct 34 ms 7500 KB Output is correct
103 Correct 44 ms 7608 KB Output is correct
104 Correct 33 ms 7488 KB Output is correct
105 Correct 33 ms 7544 KB Output is correct
106 Correct 37 ms 7756 KB Output is correct
107 Correct 40 ms 7800 KB Output is correct
108 Correct 47 ms 7764 KB Output is correct
109 Correct 37 ms 7760 KB Output is correct
110 Correct 39 ms 7776 KB Output is correct
111 Correct 39 ms 7764 KB Output is correct
112 Correct 46 ms 7764 KB Output is correct
113 Correct 37 ms 7756 KB Output is correct
114 Correct 32 ms 7760 KB Output is correct
115 Correct 41 ms 7764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2644 KB Output is correct
2 Correct 6 ms 2644 KB Output is correct
3 Correct 6 ms 2644 KB Output is correct
4 Correct 6 ms 2644 KB Output is correct
5 Correct 6 ms 2644 KB Output is correct
6 Correct 6 ms 2644 KB Output is correct
7 Correct 6 ms 2644 KB Output is correct
8 Correct 6 ms 2644 KB Output is correct
9 Correct 6 ms 2644 KB Output is correct
10 Correct 6 ms 2644 KB Output is correct
11 Correct 6 ms 2644 KB Output is correct
12 Correct 5 ms 2644 KB Output is correct
13 Correct 7 ms 2644 KB Output is correct
14 Correct 9 ms 2772 KB Output is correct
15 Correct 15 ms 3028 KB Output is correct
16 Correct 20 ms 3304 KB Output is correct
17 Correct 19 ms 3284 KB Output is correct
18 Correct 21 ms 3284 KB Output is correct
19 Correct 19 ms 3300 KB Output is correct
20 Correct 19 ms 3304 KB Output is correct
21 Correct 23 ms 3284 KB Output is correct
22 Correct 30 ms 3308 KB Output is correct
23 Correct 23 ms 3300 KB Output is correct
24 Correct 22 ms 3284 KB Output is correct
25 Correct 21 ms 3204 KB Output is correct
26 Correct 5 ms 2644 KB Output is correct
27 Correct 5 ms 2644 KB Output is correct
28 Correct 6 ms 2644 KB Output is correct
29 Correct 12 ms 2952 KB Output is correct
30 Correct 19 ms 3204 KB Output is correct
31 Correct 20 ms 3412 KB Output is correct
32 Correct 27 ms 3420 KB Output is correct
33 Correct 21 ms 3412 KB Output is correct
34 Correct 20 ms 3412 KB Output is correct
35 Correct 23 ms 3412 KB Output is correct
36 Correct 24 ms 3328 KB Output is correct
37 Correct 22 ms 3432 KB Output is correct
38 Correct 21 ms 3304 KB Output is correct
39 Correct 20 ms 3412 KB Output is correct
40 Correct 21 ms 3432 KB Output is correct
41 Correct 6 ms 2680 KB Output is correct
42 Correct 6 ms 2680 KB Output is correct
43 Correct 6 ms 2680 KB Output is correct
44 Correct 6 ms 2644 KB Output is correct
45 Correct 6 ms 2700 KB Output is correct
46 Correct 6 ms 2696 KB Output is correct
47 Correct 8 ms 2772 KB Output is correct
48 Correct 9 ms 2876 KB Output is correct
49 Correct 12 ms 3044 KB Output is correct
50 Correct 22 ms 3432 KB Output is correct
51 Correct 27 ms 3812 KB Output is correct
52 Correct 31 ms 3708 KB Output is correct
53 Correct 27 ms 3796 KB Output is correct
54 Correct 25 ms 3824 KB Output is correct
55 Correct 23 ms 3812 KB Output is correct
56 Correct 23 ms 3796 KB Output is correct
57 Correct 22 ms 3796 KB Output is correct
58 Correct 29 ms 3792 KB Output is correct
59 Correct 26 ms 3788 KB Output is correct
60 Correct 23 ms 3796 KB Output is correct
61 Correct 29 ms 3808 KB Output is correct
62 Correct 27 ms 3812 KB Output is correct
63 Correct 23 ms 3708 KB Output is correct
64 Correct 22 ms 3820 KB Output is correct
65 Correct 23 ms 3808 KB Output is correct
66 Correct 26 ms 3796 KB Output is correct
67 Correct 22 ms 3816 KB Output is correct
68 Correct 23 ms 3792 KB Output is correct
69 Correct 24 ms 3796 KB Output is correct
70 Correct 23 ms 3816 KB Output is correct
71 Correct 9 ms 2900 KB Output is correct
72 Correct 9 ms 2900 KB Output is correct
73 Correct 10 ms 2900 KB Output is correct
74 Correct 9 ms 2824 KB Output is correct
75 Correct 9 ms 2900 KB Output is correct
76 Correct 13 ms 3156 KB Output is correct
77 Correct 12 ms 3220 KB Output is correct
78 Correct 12 ms 3276 KB Output is correct
79 Correct 12 ms 3176 KB Output is correct
80 Correct 13 ms 3280 KB Output is correct
81 Correct 24 ms 3880 KB Output is correct
82 Correct 21 ms 3884 KB Output is correct
83 Correct 30 ms 3884 KB Output is correct
84 Correct 21 ms 3892 KB Output is correct
85 Correct 19 ms 3884 KB Output is correct
86 Correct 20 ms 4192 KB Output is correct
87 Correct 20 ms 4200 KB Output is correct
88 Correct 20 ms 4124 KB Output is correct
89 Correct 20 ms 4120 KB Output is correct
90 Correct 23 ms 4192 KB Output is correct
91 Correct 39 ms 5960 KB Output is correct
92 Correct 44 ms 5912 KB Output is correct
93 Correct 36 ms 5996 KB Output is correct
94 Correct 34 ms 5976 KB Output is correct
95 Correct 29 ms 5956 KB Output is correct
96 Correct 38 ms 7596 KB Output is correct
97 Correct 34 ms 7484 KB Output is correct
98 Correct 43 ms 7504 KB Output is correct
99 Correct 33 ms 7500 KB Output is correct
100 Correct 34 ms 7496 KB Output is correct
101 Correct 33 ms 7596 KB Output is correct
102 Correct 34 ms 7500 KB Output is correct
103 Correct 44 ms 7608 KB Output is correct
104 Correct 33 ms 7488 KB Output is correct
105 Correct 33 ms 7544 KB Output is correct
106 Correct 37 ms 7756 KB Output is correct
107 Correct 40 ms 7800 KB Output is correct
108 Correct 47 ms 7764 KB Output is correct
109 Correct 37 ms 7760 KB Output is correct
110 Correct 39 ms 7776 KB Output is correct
111 Correct 39 ms 7764 KB Output is correct
112 Correct 46 ms 7764 KB Output is correct
113 Correct 37 ms 7756 KB Output is correct
114 Correct 32 ms 7760 KB Output is correct
115 Correct 41 ms 7764 KB Output is correct
116 Incorrect 6 ms 2772 KB Output isn't correct
117 Halted 0 ms 0 KB -