Submission #998585

# Submission time Handle Problem Language Result Execution time Memory
998585 2024-06-14T09:41:47 Z andrei_iorgulescu Diversity (CEOI21_diversity) C++14
64 / 100
27 ms 11728 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int n,a[300005],fr[300005],q,l1,r1;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
        cin >> a[i],fr[a[i]]++;
    cin >> l1 >> r1;
    vector<int> poz_fr;
    for (int i = 1; i <= 300000; i++)
        //if (fr[i] > 0)
            poz_fr.push_back(fr[i]);
    sort(poz_fr.begin(),poz_fr.end());
    vector<int> v(poz_fr.size());
    l1 = 0,r1 = poz_fr.size() - 1;
    for (int i = 0; i < poz_fr.size(); i++)
    {
        if (i % 2 == 0)
            v[l1]  = poz_fr[i],l1++;
        else
            v[r1] = poz_fr[i],r1--;
    }
    int ans = 0;
    for (int i = 0; i < v.size(); i++)
        ans += v[i] * (v[i] + 1) / 2;
    int sumvi = 0,sumivi = 0;
    for (int j = 0; j < v.size(); j++)
    {
        ans += j * v[j] * sumvi - v[j] * sumivi + sumvi * v[j];
        sumvi += v[j];
        sumivi += j * v[j];
    }
    cout << ans;
    return 0;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:25:23: 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]
   25 |     for (int i = 0; i < poz_fr.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
diversity.cpp:33:23: 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]
   33 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
diversity.cpp:36:23: 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 j = 0; j < v.size(); j++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7372 KB Output is correct
2 Correct 8 ms 8912 KB Output is correct
3 Correct 8 ms 8656 KB Output is correct
4 Correct 8 ms 8144 KB Output is correct
5 Correct 8 ms 7120 KB Output is correct
6 Correct 8 ms 8396 KB Output is correct
7 Correct 8 ms 7900 KB Output is correct
8 Correct 8 ms 8400 KB Output is correct
9 Correct 8 ms 7324 KB Output is correct
10 Correct 8 ms 8652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8652 KB Output is correct
2 Correct 8 ms 7548 KB Output is correct
3 Correct 10 ms 8400 KB Output is correct
4 Correct 11 ms 7888 KB Output is correct
5 Correct 14 ms 8272 KB Output is correct
6 Correct 19 ms 9296 KB Output is correct
7 Correct 18 ms 7628 KB Output is correct
8 Correct 20 ms 9048 KB Output is correct
9 Correct 17 ms 8144 KB Output is correct
10 Correct 18 ms 8140 KB Output is correct
11 Correct 18 ms 8912 KB Output is correct
12 Correct 18 ms 8912 KB Output is correct
13 Correct 18 ms 8144 KB Output is correct
14 Correct 19 ms 7632 KB Output is correct
15 Correct 18 ms 8312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8652 KB Output is correct
2 Correct 8 ms 7548 KB Output is correct
3 Correct 10 ms 8400 KB Output is correct
4 Correct 11 ms 7888 KB Output is correct
5 Correct 14 ms 8272 KB Output is correct
6 Correct 19 ms 9296 KB Output is correct
7 Correct 18 ms 7628 KB Output is correct
8 Correct 20 ms 9048 KB Output is correct
9 Correct 17 ms 8144 KB Output is correct
10 Correct 18 ms 8140 KB Output is correct
11 Correct 18 ms 8912 KB Output is correct
12 Correct 18 ms 8912 KB Output is correct
13 Correct 18 ms 8144 KB Output is correct
14 Correct 19 ms 7632 KB Output is correct
15 Correct 18 ms 8312 KB Output is correct
16 Correct 8 ms 7116 KB Output is correct
17 Correct 8 ms 7632 KB Output is correct
18 Correct 8 ms 7376 KB Output is correct
19 Correct 12 ms 8260 KB Output is correct
20 Correct 16 ms 8912 KB Output is correct
21 Correct 18 ms 7628 KB Output is correct
22 Correct 18 ms 8900 KB Output is correct
23 Correct 21 ms 9156 KB Output is correct
24 Correct 19 ms 8656 KB Output is correct
25 Correct 19 ms 7548 KB Output is correct
26 Correct 19 ms 9168 KB Output is correct
27 Correct 19 ms 8284 KB Output is correct
28 Correct 19 ms 7752 KB Output is correct
29 Correct 19 ms 9168 KB Output is correct
30 Correct 18 ms 8908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8652 KB Output is correct
2 Correct 8 ms 7548 KB Output is correct
3 Correct 10 ms 8400 KB Output is correct
4 Correct 11 ms 7888 KB Output is correct
5 Correct 14 ms 8272 KB Output is correct
6 Correct 19 ms 9296 KB Output is correct
7 Correct 18 ms 7628 KB Output is correct
8 Correct 20 ms 9048 KB Output is correct
9 Correct 17 ms 8144 KB Output is correct
10 Correct 18 ms 8140 KB Output is correct
11 Correct 18 ms 8912 KB Output is correct
12 Correct 18 ms 8912 KB Output is correct
13 Correct 18 ms 8144 KB Output is correct
14 Correct 19 ms 7632 KB Output is correct
15 Correct 18 ms 8312 KB Output is correct
16 Correct 8 ms 7116 KB Output is correct
17 Correct 8 ms 7632 KB Output is correct
18 Correct 8 ms 7376 KB Output is correct
19 Correct 12 ms 8260 KB Output is correct
20 Correct 16 ms 8912 KB Output is correct
21 Correct 18 ms 7628 KB Output is correct
22 Correct 18 ms 8900 KB Output is correct
23 Correct 21 ms 9156 KB Output is correct
24 Correct 19 ms 8656 KB Output is correct
25 Correct 19 ms 7548 KB Output is correct
26 Correct 19 ms 9168 KB Output is correct
27 Correct 19 ms 8284 KB Output is correct
28 Correct 19 ms 7752 KB Output is correct
29 Correct 19 ms 9168 KB Output is correct
30 Correct 18 ms 8908 KB Output is correct
31 Correct 8 ms 8144 KB Output is correct
32 Correct 8 ms 7632 KB Output is correct
33 Correct 8 ms 7632 KB Output is correct
34 Correct 8 ms 7376 KB Output is correct
35 Correct 10 ms 8140 KB Output is correct
36 Correct 9 ms 8828 KB Output is correct
37 Correct 9 ms 7376 KB Output is correct
38 Correct 10 ms 7632 KB Output is correct
39 Correct 13 ms 8908 KB Output is correct
40 Correct 16 ms 7376 KB Output is correct
41 Correct 19 ms 7632 KB Output is correct
42 Correct 20 ms 8912 KB Output is correct
43 Correct 19 ms 9160 KB Output is correct
44 Correct 19 ms 7632 KB Output is correct
45 Correct 19 ms 9168 KB Output is correct
46 Correct 19 ms 8652 KB Output is correct
47 Correct 22 ms 8648 KB Output is correct
48 Correct 21 ms 7764 KB Output is correct
49 Correct 19 ms 8144 KB Output is correct
50 Correct 20 ms 8144 KB Output is correct
51 Correct 20 ms 8468 KB Output is correct
52 Correct 19 ms 9168 KB Output is correct
53 Correct 20 ms 8652 KB Output is correct
54 Correct 21 ms 9392 KB Output is correct
55 Correct 19 ms 7888 KB Output is correct
56 Correct 19 ms 7760 KB Output is correct
57 Correct 20 ms 9272 KB Output is correct
58 Correct 19 ms 8676 KB Output is correct
59 Correct 19 ms 8912 KB Output is correct
60 Correct 19 ms 8656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7372 KB Output is correct
2 Correct 8 ms 8912 KB Output is correct
3 Correct 8 ms 8656 KB Output is correct
4 Correct 8 ms 8144 KB Output is correct
5 Correct 8 ms 7120 KB Output is correct
6 Correct 8 ms 8396 KB Output is correct
7 Correct 8 ms 7900 KB Output is correct
8 Correct 8 ms 8400 KB Output is correct
9 Correct 8 ms 7324 KB Output is correct
10 Correct 8 ms 8652 KB Output is correct
11 Correct 8 ms 8652 KB Output is correct
12 Correct 8 ms 7548 KB Output is correct
13 Correct 10 ms 8400 KB Output is correct
14 Correct 11 ms 7888 KB Output is correct
15 Correct 14 ms 8272 KB Output is correct
16 Correct 19 ms 9296 KB Output is correct
17 Correct 18 ms 7628 KB Output is correct
18 Correct 20 ms 9048 KB Output is correct
19 Correct 17 ms 8144 KB Output is correct
20 Correct 18 ms 8140 KB Output is correct
21 Correct 18 ms 8912 KB Output is correct
22 Correct 18 ms 8912 KB Output is correct
23 Correct 18 ms 8144 KB Output is correct
24 Correct 19 ms 7632 KB Output is correct
25 Correct 18 ms 8312 KB Output is correct
26 Correct 8 ms 7116 KB Output is correct
27 Correct 8 ms 7632 KB Output is correct
28 Correct 8 ms 7376 KB Output is correct
29 Correct 12 ms 8260 KB Output is correct
30 Correct 16 ms 8912 KB Output is correct
31 Correct 18 ms 7628 KB Output is correct
32 Correct 18 ms 8900 KB Output is correct
33 Correct 21 ms 9156 KB Output is correct
34 Correct 19 ms 8656 KB Output is correct
35 Correct 19 ms 7548 KB Output is correct
36 Correct 19 ms 9168 KB Output is correct
37 Correct 19 ms 8284 KB Output is correct
38 Correct 19 ms 7752 KB Output is correct
39 Correct 19 ms 9168 KB Output is correct
40 Correct 18 ms 8908 KB Output is correct
41 Correct 8 ms 8144 KB Output is correct
42 Correct 8 ms 7632 KB Output is correct
43 Correct 8 ms 7632 KB Output is correct
44 Correct 8 ms 7376 KB Output is correct
45 Correct 10 ms 8140 KB Output is correct
46 Correct 9 ms 8828 KB Output is correct
47 Correct 9 ms 7376 KB Output is correct
48 Correct 10 ms 7632 KB Output is correct
49 Correct 13 ms 8908 KB Output is correct
50 Correct 16 ms 7376 KB Output is correct
51 Correct 19 ms 7632 KB Output is correct
52 Correct 20 ms 8912 KB Output is correct
53 Correct 19 ms 9160 KB Output is correct
54 Correct 19 ms 7632 KB Output is correct
55 Correct 19 ms 9168 KB Output is correct
56 Correct 19 ms 8652 KB Output is correct
57 Correct 22 ms 8648 KB Output is correct
58 Correct 21 ms 7764 KB Output is correct
59 Correct 19 ms 8144 KB Output is correct
60 Correct 20 ms 8144 KB Output is correct
61 Correct 20 ms 8468 KB Output is correct
62 Correct 19 ms 9168 KB Output is correct
63 Correct 20 ms 8652 KB Output is correct
64 Correct 21 ms 9392 KB Output is correct
65 Correct 19 ms 7888 KB Output is correct
66 Correct 19 ms 7760 KB Output is correct
67 Correct 20 ms 9272 KB Output is correct
68 Correct 19 ms 8676 KB Output is correct
69 Correct 19 ms 8912 KB Output is correct
70 Correct 19 ms 8656 KB Output is correct
71 Correct 14 ms 8656 KB Output is correct
72 Correct 10 ms 7888 KB Output is correct
73 Correct 10 ms 7376 KB Output is correct
74 Correct 10 ms 8392 KB Output is correct
75 Correct 10 ms 7884 KB Output is correct
76 Correct 12 ms 7172 KB Output is correct
77 Correct 14 ms 7788 KB Output is correct
78 Correct 12 ms 8816 KB Output is correct
79 Correct 12 ms 8352 KB Output is correct
80 Correct 13 ms 8908 KB Output is correct
81 Correct 17 ms 8396 KB Output is correct
82 Correct 17 ms 7376 KB Output is correct
83 Correct 17 ms 8400 KB Output is correct
84 Correct 16 ms 7372 KB Output is correct
85 Correct 17 ms 8912 KB Output is correct
86 Correct 18 ms 7912 KB Output is correct
87 Correct 17 ms 8144 KB Output is correct
88 Correct 17 ms 7396 KB Output is correct
89 Correct 18 ms 7424 KB Output is correct
90 Correct 18 ms 8144 KB Output is correct
91 Correct 25 ms 9924 KB Output is correct
92 Correct 24 ms 11460 KB Output is correct
93 Correct 24 ms 9936 KB Output is correct
94 Correct 24 ms 9924 KB Output is correct
95 Correct 24 ms 10188 KB Output is correct
96 Correct 25 ms 11320 KB Output is correct
97 Correct 25 ms 11268 KB Output is correct
98 Correct 25 ms 10036 KB Output is correct
99 Correct 25 ms 10696 KB Output is correct
100 Correct 25 ms 10188 KB Output is correct
101 Correct 26 ms 10940 KB Output is correct
102 Correct 26 ms 9976 KB Output is correct
103 Correct 26 ms 11464 KB Output is correct
104 Correct 27 ms 10580 KB Output is correct
105 Correct 25 ms 11728 KB Output is correct
106 Correct 24 ms 9936 KB Output is correct
107 Correct 24 ms 9936 KB Output is correct
108 Correct 25 ms 11188 KB Output is correct
109 Correct 25 ms 9936 KB Output is correct
110 Correct 25 ms 10264 KB Output is correct
111 Correct 25 ms 10936 KB Output is correct
112 Correct 27 ms 11464 KB Output is correct
113 Correct 26 ms 10692 KB Output is correct
114 Correct 26 ms 11508 KB Output is correct
115 Correct 25 ms 10180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7372 KB Output is correct
2 Correct 8 ms 8912 KB Output is correct
3 Correct 8 ms 8656 KB Output is correct
4 Correct 8 ms 8144 KB Output is correct
5 Correct 8 ms 7120 KB Output is correct
6 Correct 8 ms 8396 KB Output is correct
7 Correct 8 ms 7900 KB Output is correct
8 Correct 8 ms 8400 KB Output is correct
9 Correct 8 ms 7324 KB Output is correct
10 Correct 8 ms 8652 KB Output is correct
11 Correct 8 ms 8652 KB Output is correct
12 Correct 8 ms 7548 KB Output is correct
13 Correct 10 ms 8400 KB Output is correct
14 Correct 11 ms 7888 KB Output is correct
15 Correct 14 ms 8272 KB Output is correct
16 Correct 19 ms 9296 KB Output is correct
17 Correct 18 ms 7628 KB Output is correct
18 Correct 20 ms 9048 KB Output is correct
19 Correct 17 ms 8144 KB Output is correct
20 Correct 18 ms 8140 KB Output is correct
21 Correct 18 ms 8912 KB Output is correct
22 Correct 18 ms 8912 KB Output is correct
23 Correct 18 ms 8144 KB Output is correct
24 Correct 19 ms 7632 KB Output is correct
25 Correct 18 ms 8312 KB Output is correct
26 Correct 8 ms 7116 KB Output is correct
27 Correct 8 ms 7632 KB Output is correct
28 Correct 8 ms 7376 KB Output is correct
29 Correct 12 ms 8260 KB Output is correct
30 Correct 16 ms 8912 KB Output is correct
31 Correct 18 ms 7628 KB Output is correct
32 Correct 18 ms 8900 KB Output is correct
33 Correct 21 ms 9156 KB Output is correct
34 Correct 19 ms 8656 KB Output is correct
35 Correct 19 ms 7548 KB Output is correct
36 Correct 19 ms 9168 KB Output is correct
37 Correct 19 ms 8284 KB Output is correct
38 Correct 19 ms 7752 KB Output is correct
39 Correct 19 ms 9168 KB Output is correct
40 Correct 18 ms 8908 KB Output is correct
41 Correct 8 ms 8144 KB Output is correct
42 Correct 8 ms 7632 KB Output is correct
43 Correct 8 ms 7632 KB Output is correct
44 Correct 8 ms 7376 KB Output is correct
45 Correct 10 ms 8140 KB Output is correct
46 Correct 9 ms 8828 KB Output is correct
47 Correct 9 ms 7376 KB Output is correct
48 Correct 10 ms 7632 KB Output is correct
49 Correct 13 ms 8908 KB Output is correct
50 Correct 16 ms 7376 KB Output is correct
51 Correct 19 ms 7632 KB Output is correct
52 Correct 20 ms 8912 KB Output is correct
53 Correct 19 ms 9160 KB Output is correct
54 Correct 19 ms 7632 KB Output is correct
55 Correct 19 ms 9168 KB Output is correct
56 Correct 19 ms 8652 KB Output is correct
57 Correct 22 ms 8648 KB Output is correct
58 Correct 21 ms 7764 KB Output is correct
59 Correct 19 ms 8144 KB Output is correct
60 Correct 20 ms 8144 KB Output is correct
61 Correct 20 ms 8468 KB Output is correct
62 Correct 19 ms 9168 KB Output is correct
63 Correct 20 ms 8652 KB Output is correct
64 Correct 21 ms 9392 KB Output is correct
65 Correct 19 ms 7888 KB Output is correct
66 Correct 19 ms 7760 KB Output is correct
67 Correct 20 ms 9272 KB Output is correct
68 Correct 19 ms 8676 KB Output is correct
69 Correct 19 ms 8912 KB Output is correct
70 Correct 19 ms 8656 KB Output is correct
71 Correct 14 ms 8656 KB Output is correct
72 Correct 10 ms 7888 KB Output is correct
73 Correct 10 ms 7376 KB Output is correct
74 Correct 10 ms 8392 KB Output is correct
75 Correct 10 ms 7884 KB Output is correct
76 Correct 12 ms 7172 KB Output is correct
77 Correct 14 ms 7788 KB Output is correct
78 Correct 12 ms 8816 KB Output is correct
79 Correct 12 ms 8352 KB Output is correct
80 Correct 13 ms 8908 KB Output is correct
81 Correct 17 ms 8396 KB Output is correct
82 Correct 17 ms 7376 KB Output is correct
83 Correct 17 ms 8400 KB Output is correct
84 Correct 16 ms 7372 KB Output is correct
85 Correct 17 ms 8912 KB Output is correct
86 Correct 18 ms 7912 KB Output is correct
87 Correct 17 ms 8144 KB Output is correct
88 Correct 17 ms 7396 KB Output is correct
89 Correct 18 ms 7424 KB Output is correct
90 Correct 18 ms 8144 KB Output is correct
91 Correct 25 ms 9924 KB Output is correct
92 Correct 24 ms 11460 KB Output is correct
93 Correct 24 ms 9936 KB Output is correct
94 Correct 24 ms 9924 KB Output is correct
95 Correct 24 ms 10188 KB Output is correct
96 Correct 25 ms 11320 KB Output is correct
97 Correct 25 ms 11268 KB Output is correct
98 Correct 25 ms 10036 KB Output is correct
99 Correct 25 ms 10696 KB Output is correct
100 Correct 25 ms 10188 KB Output is correct
101 Correct 26 ms 10940 KB Output is correct
102 Correct 26 ms 9976 KB Output is correct
103 Correct 26 ms 11464 KB Output is correct
104 Correct 27 ms 10580 KB Output is correct
105 Correct 25 ms 11728 KB Output is correct
106 Correct 24 ms 9936 KB Output is correct
107 Correct 24 ms 9936 KB Output is correct
108 Correct 25 ms 11188 KB Output is correct
109 Correct 25 ms 9936 KB Output is correct
110 Correct 25 ms 10264 KB Output is correct
111 Correct 25 ms 10936 KB Output is correct
112 Correct 27 ms 11464 KB Output is correct
113 Correct 26 ms 10692 KB Output is correct
114 Correct 26 ms 11508 KB Output is correct
115 Correct 25 ms 10180 KB Output is correct
116 Incorrect 9 ms 8912 KB Output isn't correct
117 Halted 0 ms 0 KB -