답안 #985023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985023 2024-05-17T09:42:12 Z alexdd Diversity (CEOI21_diversity) C++17
64 / 100
42 ms 14036 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
int n,q;
int a[300005];
int fr[300005];
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>q;
    int mxm=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        fr[a[i]]++;
        mxm=max(mxm,a[i]);
    }
    int qle,qri;
    for(int i=1;i<=q;i++)
    {
        cin>>qle>>qri;
    }
    vector<int> frs,aux,aux2;
    for(int i=1;i<=mxm;i++)
        if(fr[i]) frs.push_back(fr[i]);
    sort(frs.begin(),frs.end());
    for(int i=0;i<frs.size();i+=2)
        aux.push_back(frs[i]);
    for(int i=1;i<frs.size();i+=2)
        aux2.push_back(frs[i]);
    reverse(aux2.begin(),aux2.end());
    for(auto x:aux2)
        aux.push_back(x);
    long long pref=0,rez=0;
    for(auto x:aux)
    {
        rez += (pref+x)*(n-pref);
        rez -= x*(x-1)/2;
        pref += x;
    }
    cout<<rez;
    return 0;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:29:18: 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]
   29 |     for(int i=0;i<frs.size();i+=2)
      |                 ~^~~~~~~~~~~
diversity.cpp:31:18: 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]
   31 |     for(int i=1;i<frs.size();i+=2)
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 2 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 2648 KB Output is correct
10 Correct 2 ms 2648 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 1 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 9 ms 2648 KB Output is correct
6 Correct 15 ms 3580 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 14 ms 3400 KB Output is correct
9 Correct 15 ms 3524 KB Output is correct
10 Correct 14 ms 3420 KB Output is correct
11 Correct 15 ms 3524 KB Output is correct
12 Correct 15 ms 3420 KB Output is correct
13 Correct 14 ms 3520 KB Output is correct
14 Correct 14 ms 3420 KB Output is correct
15 Correct 14 ms 3420 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 1 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 9 ms 2648 KB Output is correct
6 Correct 15 ms 3580 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 14 ms 3400 KB Output is correct
9 Correct 15 ms 3524 KB Output is correct
10 Correct 14 ms 3420 KB Output is correct
11 Correct 15 ms 3524 KB Output is correct
12 Correct 15 ms 3420 KB Output is correct
13 Correct 14 ms 3520 KB Output is correct
14 Correct 14 ms 3420 KB Output is correct
15 Correct 14 ms 3420 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 6 ms 2652 KB Output is correct
20 Correct 10 ms 2908 KB Output is correct
21 Correct 18 ms 3676 KB Output is correct
22 Correct 17 ms 3672 KB Output is correct
23 Correct 15 ms 3688 KB Output is correct
24 Correct 15 ms 3676 KB Output is correct
25 Correct 15 ms 3672 KB Output is correct
26 Correct 15 ms 3548 KB Output is correct
27 Correct 16 ms 3676 KB Output is correct
28 Correct 15 ms 3496 KB Output is correct
29 Correct 15 ms 3420 KB Output is correct
30 Correct 15 ms 3524 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 1 ms 2396 KB Output is correct
4 Correct 6 ms 2396 KB Output is correct
5 Correct 9 ms 2648 KB Output is correct
6 Correct 15 ms 3580 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 14 ms 3400 KB Output is correct
9 Correct 15 ms 3524 KB Output is correct
10 Correct 14 ms 3420 KB Output is correct
11 Correct 15 ms 3524 KB Output is correct
12 Correct 15 ms 3420 KB Output is correct
13 Correct 14 ms 3520 KB Output is correct
14 Correct 14 ms 3420 KB Output is correct
15 Correct 14 ms 3420 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 6 ms 2652 KB Output is correct
20 Correct 10 ms 2908 KB Output is correct
21 Correct 18 ms 3676 KB Output is correct
22 Correct 17 ms 3672 KB Output is correct
23 Correct 15 ms 3688 KB Output is correct
24 Correct 15 ms 3676 KB Output is correct
25 Correct 15 ms 3672 KB Output is correct
26 Correct 15 ms 3548 KB Output is correct
27 Correct 16 ms 3676 KB Output is correct
28 Correct 15 ms 3496 KB Output is correct
29 Correct 15 ms 3420 KB Output is correct
30 Correct 15 ms 3524 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 3 ms 2528 KB Output is correct
38 Correct 5 ms 2652 KB Output is correct
39 Correct 6 ms 2908 KB Output is correct
40 Correct 11 ms 3272 KB Output is correct
41 Correct 17 ms 4040 KB Output is correct
42 Correct 17 ms 3932 KB Output is correct
43 Correct 16 ms 3928 KB Output is correct
44 Correct 16 ms 3928 KB Output is correct
45 Correct 18 ms 3924 KB Output is correct
46 Correct 17 ms 3964 KB Output is correct
47 Correct 18 ms 3916 KB Output is correct
48 Correct 16 ms 3932 KB Output is correct
49 Correct 15 ms 4048 KB Output is correct
50 Correct 16 ms 3932 KB Output is correct
51 Correct 16 ms 3928 KB Output is correct
52 Correct 16 ms 3932 KB Output is correct
53 Correct 16 ms 3928 KB Output is correct
54 Correct 17 ms 3912 KB Output is correct
55 Correct 16 ms 3908 KB Output is correct
56 Correct 16 ms 3924 KB Output is correct
57 Correct 16 ms 3908 KB Output is correct
58 Correct 16 ms 3928 KB Output is correct
59 Correct 16 ms 3932 KB Output is correct
60 Correct 20 ms 4044 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 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 2 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 2648 KB Output is correct
10 Correct 2 ms 2648 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 6 ms 2396 KB Output is correct
15 Correct 9 ms 2648 KB Output is correct
16 Correct 15 ms 3580 KB Output is correct
17 Correct 14 ms 3420 KB Output is correct
18 Correct 14 ms 3400 KB Output is correct
19 Correct 15 ms 3524 KB Output is correct
20 Correct 14 ms 3420 KB Output is correct
21 Correct 15 ms 3524 KB Output is correct
22 Correct 15 ms 3420 KB Output is correct
23 Correct 14 ms 3520 KB Output is correct
24 Correct 14 ms 3420 KB Output is correct
25 Correct 14 ms 3420 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 6 ms 2652 KB Output is correct
30 Correct 10 ms 2908 KB Output is correct
31 Correct 18 ms 3676 KB Output is correct
32 Correct 17 ms 3672 KB Output is correct
33 Correct 15 ms 3688 KB Output is correct
34 Correct 15 ms 3676 KB Output is correct
35 Correct 15 ms 3672 KB Output is correct
36 Correct 15 ms 3548 KB Output is correct
37 Correct 16 ms 3676 KB Output is correct
38 Correct 15 ms 3496 KB Output is correct
39 Correct 15 ms 3420 KB Output is correct
40 Correct 15 ms 3524 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 3 ms 2528 KB Output is correct
48 Correct 5 ms 2652 KB Output is correct
49 Correct 6 ms 2908 KB Output is correct
50 Correct 11 ms 3272 KB Output is correct
51 Correct 17 ms 4040 KB Output is correct
52 Correct 17 ms 3932 KB Output is correct
53 Correct 16 ms 3928 KB Output is correct
54 Correct 16 ms 3928 KB Output is correct
55 Correct 18 ms 3924 KB Output is correct
56 Correct 17 ms 3964 KB Output is correct
57 Correct 18 ms 3916 KB Output is correct
58 Correct 16 ms 3932 KB Output is correct
59 Correct 15 ms 4048 KB Output is correct
60 Correct 16 ms 3932 KB Output is correct
61 Correct 16 ms 3928 KB Output is correct
62 Correct 16 ms 3932 KB Output is correct
63 Correct 16 ms 3928 KB Output is correct
64 Correct 17 ms 3912 KB Output is correct
65 Correct 16 ms 3908 KB Output is correct
66 Correct 16 ms 3924 KB Output is correct
67 Correct 16 ms 3908 KB Output is correct
68 Correct 16 ms 3928 KB Output is correct
69 Correct 16 ms 3932 KB Output is correct
70 Correct 20 ms 4044 KB Output is correct
71 Correct 4 ms 2652 KB Output is correct
72 Correct 4 ms 2752 KB Output is correct
73 Correct 4 ms 2648 KB Output is correct
74 Correct 5 ms 2652 KB Output is correct
75 Correct 4 ms 2652 KB Output is correct
76 Correct 7 ms 3160 KB Output is correct
77 Correct 9 ms 3024 KB Output is correct
78 Correct 7 ms 3164 KB Output is correct
79 Correct 8 ms 3164 KB Output is correct
80 Correct 8 ms 3164 KB Output is correct
81 Correct 17 ms 3720 KB Output is correct
82 Correct 13 ms 3728 KB Output is correct
83 Correct 14 ms 3852 KB Output is correct
84 Correct 13 ms 3676 KB Output is correct
85 Correct 13 ms 3676 KB Output is correct
86 Correct 15 ms 4324 KB Output is correct
87 Correct 15 ms 4320 KB Output is correct
88 Correct 15 ms 4320 KB Output is correct
89 Correct 16 ms 4196 KB Output is correct
90 Correct 17 ms 4292 KB Output is correct
91 Correct 29 ms 9948 KB Output is correct
92 Correct 25 ms 9960 KB Output is correct
93 Correct 31 ms 9688 KB Output is correct
94 Correct 24 ms 9840 KB Output is correct
95 Correct 25 ms 9676 KB Output is correct
96 Correct 33 ms 13004 KB Output is correct
97 Correct 33 ms 13012 KB Output is correct
98 Correct 31 ms 13004 KB Output is correct
99 Correct 31 ms 12780 KB Output is correct
100 Correct 38 ms 12776 KB Output is correct
101 Correct 32 ms 12992 KB Output is correct
102 Correct 30 ms 13004 KB Output is correct
103 Correct 31 ms 13004 KB Output is correct
104 Correct 42 ms 13004 KB Output is correct
105 Correct 40 ms 12828 KB Output is correct
106 Correct 38 ms 14028 KB Output is correct
107 Correct 31 ms 13768 KB Output is correct
108 Correct 35 ms 13800 KB Output is correct
109 Correct 31 ms 14036 KB Output is correct
110 Correct 32 ms 14036 KB Output is correct
111 Correct 32 ms 13772 KB Output is correct
112 Correct 34 ms 13928 KB Output is correct
113 Correct 31 ms 14036 KB Output is correct
114 Correct 31 ms 13940 KB Output is correct
115 Correct 31 ms 14028 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 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 2 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 2648 KB Output is correct
10 Correct 2 ms 2648 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 6 ms 2396 KB Output is correct
15 Correct 9 ms 2648 KB Output is correct
16 Correct 15 ms 3580 KB Output is correct
17 Correct 14 ms 3420 KB Output is correct
18 Correct 14 ms 3400 KB Output is correct
19 Correct 15 ms 3524 KB Output is correct
20 Correct 14 ms 3420 KB Output is correct
21 Correct 15 ms 3524 KB Output is correct
22 Correct 15 ms 3420 KB Output is correct
23 Correct 14 ms 3520 KB Output is correct
24 Correct 14 ms 3420 KB Output is correct
25 Correct 14 ms 3420 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 6 ms 2652 KB Output is correct
30 Correct 10 ms 2908 KB Output is correct
31 Correct 18 ms 3676 KB Output is correct
32 Correct 17 ms 3672 KB Output is correct
33 Correct 15 ms 3688 KB Output is correct
34 Correct 15 ms 3676 KB Output is correct
35 Correct 15 ms 3672 KB Output is correct
36 Correct 15 ms 3548 KB Output is correct
37 Correct 16 ms 3676 KB Output is correct
38 Correct 15 ms 3496 KB Output is correct
39 Correct 15 ms 3420 KB Output is correct
40 Correct 15 ms 3524 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 3 ms 2528 KB Output is correct
48 Correct 5 ms 2652 KB Output is correct
49 Correct 6 ms 2908 KB Output is correct
50 Correct 11 ms 3272 KB Output is correct
51 Correct 17 ms 4040 KB Output is correct
52 Correct 17 ms 3932 KB Output is correct
53 Correct 16 ms 3928 KB Output is correct
54 Correct 16 ms 3928 KB Output is correct
55 Correct 18 ms 3924 KB Output is correct
56 Correct 17 ms 3964 KB Output is correct
57 Correct 18 ms 3916 KB Output is correct
58 Correct 16 ms 3932 KB Output is correct
59 Correct 15 ms 4048 KB Output is correct
60 Correct 16 ms 3932 KB Output is correct
61 Correct 16 ms 3928 KB Output is correct
62 Correct 16 ms 3932 KB Output is correct
63 Correct 16 ms 3928 KB Output is correct
64 Correct 17 ms 3912 KB Output is correct
65 Correct 16 ms 3908 KB Output is correct
66 Correct 16 ms 3924 KB Output is correct
67 Correct 16 ms 3908 KB Output is correct
68 Correct 16 ms 3928 KB Output is correct
69 Correct 16 ms 3932 KB Output is correct
70 Correct 20 ms 4044 KB Output is correct
71 Correct 4 ms 2652 KB Output is correct
72 Correct 4 ms 2752 KB Output is correct
73 Correct 4 ms 2648 KB Output is correct
74 Correct 5 ms 2652 KB Output is correct
75 Correct 4 ms 2652 KB Output is correct
76 Correct 7 ms 3160 KB Output is correct
77 Correct 9 ms 3024 KB Output is correct
78 Correct 7 ms 3164 KB Output is correct
79 Correct 8 ms 3164 KB Output is correct
80 Correct 8 ms 3164 KB Output is correct
81 Correct 17 ms 3720 KB Output is correct
82 Correct 13 ms 3728 KB Output is correct
83 Correct 14 ms 3852 KB Output is correct
84 Correct 13 ms 3676 KB Output is correct
85 Correct 13 ms 3676 KB Output is correct
86 Correct 15 ms 4324 KB Output is correct
87 Correct 15 ms 4320 KB Output is correct
88 Correct 15 ms 4320 KB Output is correct
89 Correct 16 ms 4196 KB Output is correct
90 Correct 17 ms 4292 KB Output is correct
91 Correct 29 ms 9948 KB Output is correct
92 Correct 25 ms 9960 KB Output is correct
93 Correct 31 ms 9688 KB Output is correct
94 Correct 24 ms 9840 KB Output is correct
95 Correct 25 ms 9676 KB Output is correct
96 Correct 33 ms 13004 KB Output is correct
97 Correct 33 ms 13012 KB Output is correct
98 Correct 31 ms 13004 KB Output is correct
99 Correct 31 ms 12780 KB Output is correct
100 Correct 38 ms 12776 KB Output is correct
101 Correct 32 ms 12992 KB Output is correct
102 Correct 30 ms 13004 KB Output is correct
103 Correct 31 ms 13004 KB Output is correct
104 Correct 42 ms 13004 KB Output is correct
105 Correct 40 ms 12828 KB Output is correct
106 Correct 38 ms 14028 KB Output is correct
107 Correct 31 ms 13768 KB Output is correct
108 Correct 35 ms 13800 KB Output is correct
109 Correct 31 ms 14036 KB Output is correct
110 Correct 32 ms 14036 KB Output is correct
111 Correct 32 ms 13772 KB Output is correct
112 Correct 34 ms 13928 KB Output is correct
113 Correct 31 ms 14036 KB Output is correct
114 Correct 31 ms 13940 KB Output is correct
115 Correct 31 ms 14028 KB Output is correct
116 Incorrect 7 ms 3132 KB Output isn't correct
117 Halted 0 ms 0 KB -