Submission #713191

# Submission time Handle Problem Language Result Execution time Memory
713191 2023-03-21T09:36:10 Z Pacybwoah Diversity (CEOI21_diversity) C++14
38 / 100
7000 ms 9536 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
int main(){
    ll n,q;
    cin>>n>>q;
    if(q!=1) return 0;
    int a,b;
    vector<ll> vec(n);
    for(int i=0;i<n;i++) cin>>vec[i];
    cin>>a>>b;
    vector<ll> cnt(300001);
    for(int i=0;i<n;i++) cnt[vec[i]]++;
    vector<ll> p;
    for(int i=0;i<=300000;i++){
        if(cnt[i]>0) p.push_back(cnt[i]);
    }
    sort(p.begin(),p.end());
    vector<ll> f;
    for(int i=0;i<p.size();i+=2){
        f.push_back(p[i]);
    }
    for(int i=(p.size()%2==0?p.size()-1:p.size()-2);i>=0;i-=2) f.push_back(p[i]);
    ll sum=0,len=f.size();
    for(ll i=0;i<len;i++){
        sum+=f[i]*(f[i]+1)/2;
        for(ll j=i+1;j<len;j++){
            sum+=f[i]*f[j]*(j-i+1);
        }
    }
    cout<<sum<<"\n";
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0;i<p.size();i+=2){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2676 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 35 ms 4172 KB Output is correct
6 Correct 55 ms 4940 KB Output is correct
7 Correct 50 ms 4940 KB Output is correct
8 Correct 46 ms 4944 KB Output is correct
9 Correct 44 ms 4960 KB Output is correct
10 Correct 46 ms 4940 KB Output is correct
11 Correct 44 ms 4944 KB Output is correct
12 Correct 57 ms 4940 KB Output is correct
13 Correct 53 ms 5080 KB Output is correct
14 Correct 47 ms 4940 KB Output is correct
15 Correct 44 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2676 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 35 ms 4172 KB Output is correct
6 Correct 55 ms 4940 KB Output is correct
7 Correct 50 ms 4940 KB Output is correct
8 Correct 46 ms 4944 KB Output is correct
9 Correct 44 ms 4960 KB Output is correct
10 Correct 46 ms 4940 KB Output is correct
11 Correct 44 ms 4944 KB Output is correct
12 Correct 57 ms 4940 KB Output is correct
13 Correct 53 ms 5080 KB Output is correct
14 Correct 47 ms 4940 KB Output is correct
15 Correct 44 ms 4952 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 19 ms 3344 KB Output is correct
20 Correct 37 ms 4144 KB Output is correct
21 Correct 47 ms 4956 KB Output is correct
22 Correct 52 ms 4956 KB Output is correct
23 Correct 51 ms 4952 KB Output is correct
24 Correct 50 ms 4944 KB Output is correct
25 Correct 63 ms 4952 KB Output is correct
26 Correct 47 ms 4948 KB Output is correct
27 Correct 54 ms 4940 KB Output is correct
28 Correct 57 ms 4940 KB Output is correct
29 Correct 55 ms 4940 KB Output is correct
30 Correct 48 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2676 KB Output is correct
4 Correct 22 ms 3412 KB Output is correct
5 Correct 35 ms 4172 KB Output is correct
6 Correct 55 ms 4940 KB Output is correct
7 Correct 50 ms 4940 KB Output is correct
8 Correct 46 ms 4944 KB Output is correct
9 Correct 44 ms 4960 KB Output is correct
10 Correct 46 ms 4940 KB Output is correct
11 Correct 44 ms 4944 KB Output is correct
12 Correct 57 ms 4940 KB Output is correct
13 Correct 53 ms 5080 KB Output is correct
14 Correct 47 ms 4940 KB Output is correct
15 Correct 44 ms 4952 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 19 ms 3344 KB Output is correct
20 Correct 37 ms 4144 KB Output is correct
21 Correct 47 ms 4956 KB Output is correct
22 Correct 52 ms 4956 KB Output is correct
23 Correct 51 ms 4952 KB Output is correct
24 Correct 50 ms 4944 KB Output is correct
25 Correct 63 ms 4952 KB Output is correct
26 Correct 47 ms 4948 KB Output is correct
27 Correct 54 ms 4940 KB Output is correct
28 Correct 57 ms 4940 KB Output is correct
29 Correct 55 ms 4940 KB Output is correct
30 Correct 48 ms 4952 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 5 ms 2644 KB Output is correct
35 Correct 4 ms 2644 KB Output is correct
36 Correct 6 ms 2644 KB Output is correct
37 Correct 11 ms 3000 KB Output is correct
38 Correct 13 ms 3028 KB Output is correct
39 Correct 25 ms 3348 KB Output is correct
40 Correct 48 ms 4176 KB Output is correct
41 Correct 62 ms 4936 KB Output is correct
42 Correct 64 ms 5004 KB Output is correct
43 Correct 59 ms 4936 KB Output is correct
44 Correct 58 ms 4948 KB Output is correct
45 Correct 58 ms 4956 KB Output is correct
46 Correct 61 ms 4944 KB Output is correct
47 Correct 58 ms 4948 KB Output is correct
48 Correct 71 ms 4944 KB Output is correct
49 Correct 66 ms 4940 KB Output is correct
50 Correct 59 ms 4948 KB Output is correct
51 Correct 58 ms 4944 KB Output is correct
52 Correct 61 ms 4940 KB Output is correct
53 Correct 63 ms 4940 KB Output is correct
54 Correct 59 ms 4952 KB Output is correct
55 Correct 58 ms 4952 KB Output is correct
56 Correct 60 ms 4940 KB Output is correct
57 Correct 58 ms 4940 KB Output is correct
58 Correct 59 ms 4936 KB Output is correct
59 Correct 64 ms 4956 KB Output is correct
60 Correct 59 ms 4936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 3 ms 2676 KB Output is correct
14 Correct 22 ms 3412 KB Output is correct
15 Correct 35 ms 4172 KB Output is correct
16 Correct 55 ms 4940 KB Output is correct
17 Correct 50 ms 4940 KB Output is correct
18 Correct 46 ms 4944 KB Output is correct
19 Correct 44 ms 4960 KB Output is correct
20 Correct 46 ms 4940 KB Output is correct
21 Correct 44 ms 4944 KB Output is correct
22 Correct 57 ms 4940 KB Output is correct
23 Correct 53 ms 5080 KB Output is correct
24 Correct 47 ms 4940 KB Output is correct
25 Correct 44 ms 4952 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 3 ms 2644 KB Output is correct
29 Correct 19 ms 3344 KB Output is correct
30 Correct 37 ms 4144 KB Output is correct
31 Correct 47 ms 4956 KB Output is correct
32 Correct 52 ms 4956 KB Output is correct
33 Correct 51 ms 4952 KB Output is correct
34 Correct 50 ms 4944 KB Output is correct
35 Correct 63 ms 4952 KB Output is correct
36 Correct 47 ms 4948 KB Output is correct
37 Correct 54 ms 4940 KB Output is correct
38 Correct 57 ms 4940 KB Output is correct
39 Correct 55 ms 4940 KB Output is correct
40 Correct 48 ms 4952 KB Output is correct
41 Correct 2 ms 2644 KB Output is correct
42 Correct 2 ms 2644 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 5 ms 2644 KB Output is correct
45 Correct 4 ms 2644 KB Output is correct
46 Correct 6 ms 2644 KB Output is correct
47 Correct 11 ms 3000 KB Output is correct
48 Correct 13 ms 3028 KB Output is correct
49 Correct 25 ms 3348 KB Output is correct
50 Correct 48 ms 4176 KB Output is correct
51 Correct 62 ms 4936 KB Output is correct
52 Correct 64 ms 5004 KB Output is correct
53 Correct 59 ms 4936 KB Output is correct
54 Correct 58 ms 4948 KB Output is correct
55 Correct 58 ms 4956 KB Output is correct
56 Correct 61 ms 4944 KB Output is correct
57 Correct 58 ms 4948 KB Output is correct
58 Correct 71 ms 4944 KB Output is correct
59 Correct 66 ms 4940 KB Output is correct
60 Correct 59 ms 4948 KB Output is correct
61 Correct 58 ms 4944 KB Output is correct
62 Correct 61 ms 4940 KB Output is correct
63 Correct 63 ms 4940 KB Output is correct
64 Correct 59 ms 4952 KB Output is correct
65 Correct 58 ms 4952 KB Output is correct
66 Correct 60 ms 4940 KB Output is correct
67 Correct 58 ms 4940 KB Output is correct
68 Correct 59 ms 4936 KB Output is correct
69 Correct 64 ms 4956 KB Output is correct
70 Correct 59 ms 4936 KB Output is correct
71 Correct 13 ms 3028 KB Output is correct
72 Correct 14 ms 3008 KB Output is correct
73 Correct 13 ms 3004 KB Output is correct
74 Correct 14 ms 3072 KB Output is correct
75 Correct 14 ms 3028 KB Output is correct
76 Correct 34 ms 3524 KB Output is correct
77 Correct 33 ms 3520 KB Output is correct
78 Correct 31 ms 3576 KB Output is correct
79 Correct 33 ms 3508 KB Output is correct
80 Correct 34 ms 3516 KB Output is correct
81 Correct 83 ms 4424 KB Output is correct
82 Correct 81 ms 4432 KB Output is correct
83 Correct 79 ms 4420 KB Output is correct
84 Correct 84 ms 4488 KB Output is correct
85 Correct 87 ms 4416 KB Output is correct
86 Correct 201 ms 4664 KB Output is correct
87 Correct 188 ms 4664 KB Output is correct
88 Correct 206 ms 4684 KB Output is correct
89 Correct 189 ms 4680 KB Output is correct
90 Correct 194 ms 4660 KB Output is correct
91 Correct 3693 ms 7228 KB Output is correct
92 Correct 3644 ms 7240 KB Output is correct
93 Correct 3588 ms 7232 KB Output is correct
94 Correct 3694 ms 7236 KB Output is correct
95 Correct 3608 ms 7228 KB Output is correct
96 Execution timed out 7090 ms 9536 KB Time limit exceeded
97 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 3 ms 2676 KB Output is correct
14 Correct 22 ms 3412 KB Output is correct
15 Correct 35 ms 4172 KB Output is correct
16 Correct 55 ms 4940 KB Output is correct
17 Correct 50 ms 4940 KB Output is correct
18 Correct 46 ms 4944 KB Output is correct
19 Correct 44 ms 4960 KB Output is correct
20 Correct 46 ms 4940 KB Output is correct
21 Correct 44 ms 4944 KB Output is correct
22 Correct 57 ms 4940 KB Output is correct
23 Correct 53 ms 5080 KB Output is correct
24 Correct 47 ms 4940 KB Output is correct
25 Correct 44 ms 4952 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 3 ms 2644 KB Output is correct
29 Correct 19 ms 3344 KB Output is correct
30 Correct 37 ms 4144 KB Output is correct
31 Correct 47 ms 4956 KB Output is correct
32 Correct 52 ms 4956 KB Output is correct
33 Correct 51 ms 4952 KB Output is correct
34 Correct 50 ms 4944 KB Output is correct
35 Correct 63 ms 4952 KB Output is correct
36 Correct 47 ms 4948 KB Output is correct
37 Correct 54 ms 4940 KB Output is correct
38 Correct 57 ms 4940 KB Output is correct
39 Correct 55 ms 4940 KB Output is correct
40 Correct 48 ms 4952 KB Output is correct
41 Correct 2 ms 2644 KB Output is correct
42 Correct 2 ms 2644 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 5 ms 2644 KB Output is correct
45 Correct 4 ms 2644 KB Output is correct
46 Correct 6 ms 2644 KB Output is correct
47 Correct 11 ms 3000 KB Output is correct
48 Correct 13 ms 3028 KB Output is correct
49 Correct 25 ms 3348 KB Output is correct
50 Correct 48 ms 4176 KB Output is correct
51 Correct 62 ms 4936 KB Output is correct
52 Correct 64 ms 5004 KB Output is correct
53 Correct 59 ms 4936 KB Output is correct
54 Correct 58 ms 4948 KB Output is correct
55 Correct 58 ms 4956 KB Output is correct
56 Correct 61 ms 4944 KB Output is correct
57 Correct 58 ms 4948 KB Output is correct
58 Correct 71 ms 4944 KB Output is correct
59 Correct 66 ms 4940 KB Output is correct
60 Correct 59 ms 4948 KB Output is correct
61 Correct 58 ms 4944 KB Output is correct
62 Correct 61 ms 4940 KB Output is correct
63 Correct 63 ms 4940 KB Output is correct
64 Correct 59 ms 4952 KB Output is correct
65 Correct 58 ms 4952 KB Output is correct
66 Correct 60 ms 4940 KB Output is correct
67 Correct 58 ms 4940 KB Output is correct
68 Correct 59 ms 4936 KB Output is correct
69 Correct 64 ms 4956 KB Output is correct
70 Correct 59 ms 4936 KB Output is correct
71 Correct 13 ms 3028 KB Output is correct
72 Correct 14 ms 3008 KB Output is correct
73 Correct 13 ms 3004 KB Output is correct
74 Correct 14 ms 3072 KB Output is correct
75 Correct 14 ms 3028 KB Output is correct
76 Correct 34 ms 3524 KB Output is correct
77 Correct 33 ms 3520 KB Output is correct
78 Correct 31 ms 3576 KB Output is correct
79 Correct 33 ms 3508 KB Output is correct
80 Correct 34 ms 3516 KB Output is correct
81 Correct 83 ms 4424 KB Output is correct
82 Correct 81 ms 4432 KB Output is correct
83 Correct 79 ms 4420 KB Output is correct
84 Correct 84 ms 4488 KB Output is correct
85 Correct 87 ms 4416 KB Output is correct
86 Correct 201 ms 4664 KB Output is correct
87 Correct 188 ms 4664 KB Output is correct
88 Correct 206 ms 4684 KB Output is correct
89 Correct 189 ms 4680 KB Output is correct
90 Correct 194 ms 4660 KB Output is correct
91 Correct 3693 ms 7228 KB Output is correct
92 Correct 3644 ms 7240 KB Output is correct
93 Correct 3588 ms 7232 KB Output is correct
94 Correct 3694 ms 7236 KB Output is correct
95 Correct 3608 ms 7228 KB Output is correct
96 Execution timed out 7090 ms 9536 KB Time limit exceeded
97 Halted 0 ms 0 KB -