답안 #998575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998575 2024-06-14T09:12:52 Z andrei_iorgulescu Diversity (CEOI21_diversity) C++14
64 / 100
75 ms 11200 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

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

signed main()
{
    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:22: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]
   22 |     for (int i = 0; i < poz_fr.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
diversity.cpp:30: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]
   30 |     for (int i = 0; i < v.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 j = 0; j < v.size(); j++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2492 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 16 ms 2652 KB Output is correct
6 Correct 28 ms 3500 KB Output is correct
7 Correct 25 ms 3372 KB Output is correct
8 Correct 26 ms 3492 KB Output is correct
9 Correct 26 ms 3496 KB Output is correct
10 Correct 33 ms 3412 KB Output is correct
11 Correct 26 ms 3500 KB Output is correct
12 Correct 27 ms 3528 KB Output is correct
13 Correct 26 ms 3412 KB Output is correct
14 Correct 26 ms 3416 KB Output is correct
15 Correct 25 ms 3484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 16 ms 2652 KB Output is correct
6 Correct 28 ms 3500 KB Output is correct
7 Correct 25 ms 3372 KB Output is correct
8 Correct 26 ms 3492 KB Output is correct
9 Correct 26 ms 3496 KB Output is correct
10 Correct 33 ms 3412 KB Output is correct
11 Correct 26 ms 3500 KB Output is correct
12 Correct 27 ms 3528 KB Output is correct
13 Correct 26 ms 3412 KB Output is correct
14 Correct 26 ms 3416 KB Output is correct
15 Correct 25 ms 3484 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 15 ms 2648 KB Output is correct
20 Correct 21 ms 2904 KB Output is correct
21 Correct 29 ms 3460 KB Output is correct
22 Correct 30 ms 3668 KB Output is correct
23 Correct 30 ms 3480 KB Output is correct
24 Correct 29 ms 3616 KB Output is correct
25 Correct 30 ms 3676 KB Output is correct
26 Correct 31 ms 3416 KB Output is correct
27 Correct 30 ms 3416 KB Output is correct
28 Correct 29 ms 3364 KB Output is correct
29 Correct 29 ms 3628 KB Output is correct
30 Correct 31 ms 3620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 9 ms 2652 KB Output is correct
5 Correct 16 ms 2652 KB Output is correct
6 Correct 28 ms 3500 KB Output is correct
7 Correct 25 ms 3372 KB Output is correct
8 Correct 26 ms 3492 KB Output is correct
9 Correct 26 ms 3496 KB Output is correct
10 Correct 33 ms 3412 KB Output is correct
11 Correct 26 ms 3500 KB Output is correct
12 Correct 27 ms 3528 KB Output is correct
13 Correct 26 ms 3412 KB Output is correct
14 Correct 26 ms 3416 KB Output is correct
15 Correct 25 ms 3484 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 15 ms 2648 KB Output is correct
20 Correct 21 ms 2904 KB Output is correct
21 Correct 29 ms 3460 KB Output is correct
22 Correct 30 ms 3668 KB Output is correct
23 Correct 30 ms 3480 KB Output is correct
24 Correct 29 ms 3616 KB Output is correct
25 Correct 30 ms 3676 KB Output is correct
26 Correct 31 ms 3416 KB Output is correct
27 Correct 30 ms 3416 KB Output is correct
28 Correct 29 ms 3364 KB Output is correct
29 Correct 29 ms 3628 KB Output is correct
30 Correct 31 ms 3620 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2492 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2396 KB Output is correct
36 Correct 2 ms 2396 KB Output is correct
37 Correct 6 ms 2904 KB Output is correct
38 Correct 7 ms 2652 KB Output is correct
39 Correct 12 ms 2876 KB Output is correct
40 Correct 23 ms 3256 KB Output is correct
41 Correct 37 ms 4052 KB Output is correct
42 Correct 36 ms 3884 KB Output is correct
43 Correct 35 ms 3920 KB Output is correct
44 Correct 35 ms 3924 KB Output is correct
45 Correct 35 ms 3932 KB Output is correct
46 Correct 35 ms 4004 KB Output is correct
47 Correct 35 ms 4012 KB Output is correct
48 Correct 37 ms 3924 KB Output is correct
49 Correct 34 ms 3932 KB Output is correct
50 Correct 35 ms 3924 KB Output is correct
51 Correct 34 ms 3924 KB Output is correct
52 Correct 35 ms 3920 KB Output is correct
53 Correct 35 ms 3880 KB Output is correct
54 Correct 36 ms 3920 KB Output is correct
55 Correct 34 ms 3880 KB Output is correct
56 Correct 51 ms 3920 KB Output is correct
57 Correct 35 ms 3920 KB Output is correct
58 Correct 38 ms 3924 KB Output is correct
59 Correct 35 ms 3880 KB Output is correct
60 Correct 35 ms 4020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2492 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 9 ms 2652 KB Output is correct
15 Correct 16 ms 2652 KB Output is correct
16 Correct 28 ms 3500 KB Output is correct
17 Correct 25 ms 3372 KB Output is correct
18 Correct 26 ms 3492 KB Output is correct
19 Correct 26 ms 3496 KB Output is correct
20 Correct 33 ms 3412 KB Output is correct
21 Correct 26 ms 3500 KB Output is correct
22 Correct 27 ms 3528 KB Output is correct
23 Correct 26 ms 3412 KB Output is correct
24 Correct 26 ms 3416 KB Output is correct
25 Correct 25 ms 3484 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 15 ms 2648 KB Output is correct
30 Correct 21 ms 2904 KB Output is correct
31 Correct 29 ms 3460 KB Output is correct
32 Correct 30 ms 3668 KB Output is correct
33 Correct 30 ms 3480 KB Output is correct
34 Correct 29 ms 3616 KB Output is correct
35 Correct 30 ms 3676 KB Output is correct
36 Correct 31 ms 3416 KB Output is correct
37 Correct 30 ms 3416 KB Output is correct
38 Correct 29 ms 3364 KB Output is correct
39 Correct 29 ms 3628 KB Output is correct
40 Correct 31 ms 3620 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2492 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 2 ms 2396 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 6 ms 2904 KB Output is correct
48 Correct 7 ms 2652 KB Output is correct
49 Correct 12 ms 2876 KB Output is correct
50 Correct 23 ms 3256 KB Output is correct
51 Correct 37 ms 4052 KB Output is correct
52 Correct 36 ms 3884 KB Output is correct
53 Correct 35 ms 3920 KB Output is correct
54 Correct 35 ms 3924 KB Output is correct
55 Correct 35 ms 3932 KB Output is correct
56 Correct 35 ms 4004 KB Output is correct
57 Correct 35 ms 4012 KB Output is correct
58 Correct 37 ms 3924 KB Output is correct
59 Correct 34 ms 3932 KB Output is correct
60 Correct 35 ms 3924 KB Output is correct
61 Correct 34 ms 3924 KB Output is correct
62 Correct 35 ms 3920 KB Output is correct
63 Correct 35 ms 3880 KB Output is correct
64 Correct 36 ms 3920 KB Output is correct
65 Correct 34 ms 3880 KB Output is correct
66 Correct 51 ms 3920 KB Output is correct
67 Correct 35 ms 3920 KB Output is correct
68 Correct 38 ms 3924 KB Output is correct
69 Correct 35 ms 3880 KB Output is correct
70 Correct 35 ms 4020 KB Output is correct
71 Correct 7 ms 2648 KB Output is correct
72 Correct 7 ms 2760 KB Output is correct
73 Correct 8 ms 2652 KB Output is correct
74 Correct 7 ms 2728 KB Output is correct
75 Correct 8 ms 2756 KB Output is correct
76 Correct 17 ms 2908 KB Output is correct
77 Correct 15 ms 2908 KB Output is correct
78 Correct 15 ms 2908 KB Output is correct
79 Correct 14 ms 2908 KB Output is correct
80 Correct 14 ms 3020 KB Output is correct
81 Correct 29 ms 3704 KB Output is correct
82 Correct 29 ms 3668 KB Output is correct
83 Correct 31 ms 3676 KB Output is correct
84 Correct 28 ms 3568 KB Output is correct
85 Correct 29 ms 3672 KB Output is correct
86 Correct 31 ms 4036 KB Output is correct
87 Correct 30 ms 4048 KB Output is correct
88 Correct 31 ms 4044 KB Output is correct
89 Correct 31 ms 4048 KB Output is correct
90 Correct 31 ms 4048 KB Output is correct
91 Correct 50 ms 8136 KB Output is correct
92 Correct 50 ms 8132 KB Output is correct
93 Correct 50 ms 8140 KB Output is correct
94 Correct 49 ms 8340 KB Output is correct
95 Correct 50 ms 8136 KB Output is correct
96 Correct 60 ms 10176 KB Output is correct
97 Correct 57 ms 9664 KB Output is correct
98 Correct 56 ms 9412 KB Output is correct
99 Correct 57 ms 10056 KB Output is correct
100 Correct 58 ms 10036 KB Output is correct
101 Correct 56 ms 10176 KB Output is correct
102 Correct 59 ms 10188 KB Output is correct
103 Correct 57 ms 10184 KB Output is correct
104 Correct 56 ms 10176 KB Output is correct
105 Correct 56 ms 10180 KB Output is correct
106 Correct 60 ms 10944 KB Output is correct
107 Correct 59 ms 11096 KB Output is correct
108 Correct 59 ms 10944 KB Output is correct
109 Correct 61 ms 10948 KB Output is correct
110 Correct 75 ms 10952 KB Output is correct
111 Correct 62 ms 11200 KB Output is correct
112 Correct 63 ms 11084 KB Output is correct
113 Correct 61 ms 10940 KB Output is correct
114 Correct 58 ms 10940 KB Output is correct
115 Correct 57 ms 10944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2492 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 9 ms 2652 KB Output is correct
15 Correct 16 ms 2652 KB Output is correct
16 Correct 28 ms 3500 KB Output is correct
17 Correct 25 ms 3372 KB Output is correct
18 Correct 26 ms 3492 KB Output is correct
19 Correct 26 ms 3496 KB Output is correct
20 Correct 33 ms 3412 KB Output is correct
21 Correct 26 ms 3500 KB Output is correct
22 Correct 27 ms 3528 KB Output is correct
23 Correct 26 ms 3412 KB Output is correct
24 Correct 26 ms 3416 KB Output is correct
25 Correct 25 ms 3484 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 15 ms 2648 KB Output is correct
30 Correct 21 ms 2904 KB Output is correct
31 Correct 29 ms 3460 KB Output is correct
32 Correct 30 ms 3668 KB Output is correct
33 Correct 30 ms 3480 KB Output is correct
34 Correct 29 ms 3616 KB Output is correct
35 Correct 30 ms 3676 KB Output is correct
36 Correct 31 ms 3416 KB Output is correct
37 Correct 30 ms 3416 KB Output is correct
38 Correct 29 ms 3364 KB Output is correct
39 Correct 29 ms 3628 KB Output is correct
40 Correct 31 ms 3620 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2492 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 2 ms 2396 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 6 ms 2904 KB Output is correct
48 Correct 7 ms 2652 KB Output is correct
49 Correct 12 ms 2876 KB Output is correct
50 Correct 23 ms 3256 KB Output is correct
51 Correct 37 ms 4052 KB Output is correct
52 Correct 36 ms 3884 KB Output is correct
53 Correct 35 ms 3920 KB Output is correct
54 Correct 35 ms 3924 KB Output is correct
55 Correct 35 ms 3932 KB Output is correct
56 Correct 35 ms 4004 KB Output is correct
57 Correct 35 ms 4012 KB Output is correct
58 Correct 37 ms 3924 KB Output is correct
59 Correct 34 ms 3932 KB Output is correct
60 Correct 35 ms 3924 KB Output is correct
61 Correct 34 ms 3924 KB Output is correct
62 Correct 35 ms 3920 KB Output is correct
63 Correct 35 ms 3880 KB Output is correct
64 Correct 36 ms 3920 KB Output is correct
65 Correct 34 ms 3880 KB Output is correct
66 Correct 51 ms 3920 KB Output is correct
67 Correct 35 ms 3920 KB Output is correct
68 Correct 38 ms 3924 KB Output is correct
69 Correct 35 ms 3880 KB Output is correct
70 Correct 35 ms 4020 KB Output is correct
71 Correct 7 ms 2648 KB Output is correct
72 Correct 7 ms 2760 KB Output is correct
73 Correct 8 ms 2652 KB Output is correct
74 Correct 7 ms 2728 KB Output is correct
75 Correct 8 ms 2756 KB Output is correct
76 Correct 17 ms 2908 KB Output is correct
77 Correct 15 ms 2908 KB Output is correct
78 Correct 15 ms 2908 KB Output is correct
79 Correct 14 ms 2908 KB Output is correct
80 Correct 14 ms 3020 KB Output is correct
81 Correct 29 ms 3704 KB Output is correct
82 Correct 29 ms 3668 KB Output is correct
83 Correct 31 ms 3676 KB Output is correct
84 Correct 28 ms 3568 KB Output is correct
85 Correct 29 ms 3672 KB Output is correct
86 Correct 31 ms 4036 KB Output is correct
87 Correct 30 ms 4048 KB Output is correct
88 Correct 31 ms 4044 KB Output is correct
89 Correct 31 ms 4048 KB Output is correct
90 Correct 31 ms 4048 KB Output is correct
91 Correct 50 ms 8136 KB Output is correct
92 Correct 50 ms 8132 KB Output is correct
93 Correct 50 ms 8140 KB Output is correct
94 Correct 49 ms 8340 KB Output is correct
95 Correct 50 ms 8136 KB Output is correct
96 Correct 60 ms 10176 KB Output is correct
97 Correct 57 ms 9664 KB Output is correct
98 Correct 56 ms 9412 KB Output is correct
99 Correct 57 ms 10056 KB Output is correct
100 Correct 58 ms 10036 KB Output is correct
101 Correct 56 ms 10176 KB Output is correct
102 Correct 59 ms 10188 KB Output is correct
103 Correct 57 ms 10184 KB Output is correct
104 Correct 56 ms 10176 KB Output is correct
105 Correct 56 ms 10180 KB Output is correct
106 Correct 60 ms 10944 KB Output is correct
107 Correct 59 ms 11096 KB Output is correct
108 Correct 59 ms 10944 KB Output is correct
109 Correct 61 ms 10948 KB Output is correct
110 Correct 75 ms 10952 KB Output is correct
111 Correct 62 ms 11200 KB Output is correct
112 Correct 63 ms 11084 KB Output is correct
113 Correct 61 ms 10940 KB Output is correct
114 Correct 58 ms 10940 KB Output is correct
115 Correct 57 ms 10944 KB Output is correct
116 Incorrect 2 ms 2392 KB Output isn't correct
117 Halted 0 ms 0 KB -