Submission #967558

# Submission time Handle Problem Language Result Execution time Memory
967558 2024-04-22T12:33:55 Z anton Diversity (CEOI21_diversity) C++17
38 / 100
7000 ms 12996 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
#define pii pair<int, int>


int arithmetic(int v){
    return v*(v+1)/2;
}
signed main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n, q;
    cin>>n>>q;
    vector<int> v(n);
    map<int, int> oc;
    for(int i = 0; i<n; i++){
        cin>>v[i];
        oc[v[i]] ++;
    }

    deque<int> dq;
    vector<pii> groups;
    for(auto e: oc){
        groups.push_back(e);
    }
    auto cmp =[&](pii& a, pii& b){
        return a.second>b.second;
    };
    sort(groups.begin(), groups.end(), cmp);


    int res= 0;
    for(int i = 0; i<groups.size(); i++){
        if(i%2 == 0){
            dq.push_back(groups[i].second);
        }
        else{
            dq.push_front(groups[i].second);
        }
        res += arithmetic(groups[i].second);
    }


    for(int dist= 1; dist<dq.size(); dist++){
        for(int i =0; i<dq.size()-dist; i++){
            res += (dist+1)*dq[i] * dq[i + dist];
        }
    }
    for(int i = 0; i<q; i++){
        int a, b;
        cin>>a>>b;
        cout<<res<<endl;
    }

}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:35:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0; i<groups.size(); i++){
      |                    ~^~~~~~~~~~~~~~
diversity.cpp:46:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int dist= 1; dist<dq.size(); dist++){
      |                      ~~~~^~~~~~~~~~
diversity.cpp:47:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   47 |         for(int i =0; i<dq.size()-dist; i++){
      |                       ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 584 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 6 ms 1372 KB Output is correct
5 Correct 10 ms 2392 KB Output is correct
6 Correct 16 ms 3420 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 17 ms 3416 KB Output is correct
9 Correct 17 ms 3672 KB Output is correct
10 Correct 19 ms 3416 KB Output is correct
11 Correct 16 ms 3420 KB Output is correct
12 Correct 17 ms 3416 KB Output is correct
13 Correct 17 ms 3308 KB Output is correct
14 Correct 17 ms 3420 KB Output is correct
15 Correct 16 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 6 ms 1372 KB Output is correct
5 Correct 10 ms 2392 KB Output is correct
6 Correct 16 ms 3420 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 17 ms 3416 KB Output is correct
9 Correct 17 ms 3672 KB Output is correct
10 Correct 19 ms 3416 KB Output is correct
11 Correct 16 ms 3420 KB Output is correct
12 Correct 17 ms 3416 KB Output is correct
13 Correct 17 ms 3308 KB Output is correct
14 Correct 17 ms 3420 KB Output is correct
15 Correct 16 ms 3420 KB Output is correct
16 Correct 0 ms 548 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 6 ms 1368 KB Output is correct
20 Correct 12 ms 2532 KB Output is correct
21 Correct 18 ms 3420 KB Output is correct
22 Correct 18 ms 3596 KB Output is correct
23 Correct 20 ms 3416 KB Output is correct
24 Correct 21 ms 3420 KB Output is correct
25 Correct 19 ms 3592 KB Output is correct
26 Correct 19 ms 3416 KB Output is correct
27 Correct 18 ms 3416 KB Output is correct
28 Correct 18 ms 3416 KB Output is correct
29 Correct 19 ms 3420 KB Output is correct
30 Correct 19 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 6 ms 1372 KB Output is correct
5 Correct 10 ms 2392 KB Output is correct
6 Correct 16 ms 3420 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 17 ms 3416 KB Output is correct
9 Correct 17 ms 3672 KB Output is correct
10 Correct 19 ms 3416 KB Output is correct
11 Correct 16 ms 3420 KB Output is correct
12 Correct 17 ms 3416 KB Output is correct
13 Correct 17 ms 3308 KB Output is correct
14 Correct 17 ms 3420 KB Output is correct
15 Correct 16 ms 3420 KB Output is correct
16 Correct 0 ms 548 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 6 ms 1368 KB Output is correct
20 Correct 12 ms 2532 KB Output is correct
21 Correct 18 ms 3420 KB Output is correct
22 Correct 18 ms 3596 KB Output is correct
23 Correct 20 ms 3416 KB Output is correct
24 Correct 21 ms 3420 KB Output is correct
25 Correct 19 ms 3592 KB Output is correct
26 Correct 19 ms 3416 KB Output is correct
27 Correct 18 ms 3416 KB Output is correct
28 Correct 18 ms 3416 KB Output is correct
29 Correct 19 ms 3420 KB Output is correct
30 Correct 19 ms 3676 KB Output is correct
31 Correct 0 ms 456 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 3 ms 468 KB Output is correct
37 Correct 5 ms 860 KB Output is correct
38 Correct 6 ms 1112 KB Output is correct
39 Correct 11 ms 1676 KB Output is correct
40 Correct 21 ms 2864 KB Output is correct
41 Correct 34 ms 3932 KB Output is correct
42 Correct 31 ms 3996 KB Output is correct
43 Correct 31 ms 4008 KB Output is correct
44 Correct 30 ms 3932 KB Output is correct
45 Correct 30 ms 4196 KB Output is correct
46 Correct 30 ms 3868 KB Output is correct
47 Correct 30 ms 3920 KB Output is correct
48 Correct 30 ms 3928 KB Output is correct
49 Correct 31 ms 3920 KB Output is correct
50 Correct 32 ms 3924 KB Output is correct
51 Correct 36 ms 3924 KB Output is correct
52 Correct 30 ms 4016 KB Output is correct
53 Correct 30 ms 3932 KB Output is correct
54 Correct 37 ms 3932 KB Output is correct
55 Correct 30 ms 3920 KB Output is correct
56 Correct 30 ms 3920 KB Output is correct
57 Correct 31 ms 3932 KB Output is correct
58 Correct 34 ms 4032 KB Output is correct
59 Correct 30 ms 4012 KB Output is correct
60 Correct 35 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 584 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 1372 KB Output is correct
15 Correct 10 ms 2392 KB Output is correct
16 Correct 16 ms 3420 KB Output is correct
17 Correct 14 ms 3420 KB Output is correct
18 Correct 17 ms 3416 KB Output is correct
19 Correct 17 ms 3672 KB Output is correct
20 Correct 19 ms 3416 KB Output is correct
21 Correct 16 ms 3420 KB Output is correct
22 Correct 17 ms 3416 KB Output is correct
23 Correct 17 ms 3308 KB Output is correct
24 Correct 17 ms 3420 KB Output is correct
25 Correct 16 ms 3420 KB Output is correct
26 Correct 0 ms 548 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 6 ms 1368 KB Output is correct
30 Correct 12 ms 2532 KB Output is correct
31 Correct 18 ms 3420 KB Output is correct
32 Correct 18 ms 3596 KB Output is correct
33 Correct 20 ms 3416 KB Output is correct
34 Correct 21 ms 3420 KB Output is correct
35 Correct 19 ms 3592 KB Output is correct
36 Correct 19 ms 3416 KB Output is correct
37 Correct 18 ms 3416 KB Output is correct
38 Correct 18 ms 3416 KB Output is correct
39 Correct 19 ms 3420 KB Output is correct
40 Correct 19 ms 3676 KB Output is correct
41 Correct 0 ms 456 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 5 ms 860 KB Output is correct
48 Correct 6 ms 1112 KB Output is correct
49 Correct 11 ms 1676 KB Output is correct
50 Correct 21 ms 2864 KB Output is correct
51 Correct 34 ms 3932 KB Output is correct
52 Correct 31 ms 3996 KB Output is correct
53 Correct 31 ms 4008 KB Output is correct
54 Correct 30 ms 3932 KB Output is correct
55 Correct 30 ms 4196 KB Output is correct
56 Correct 30 ms 3868 KB Output is correct
57 Correct 30 ms 3920 KB Output is correct
58 Correct 30 ms 3928 KB Output is correct
59 Correct 31 ms 3920 KB Output is correct
60 Correct 32 ms 3924 KB Output is correct
61 Correct 36 ms 3924 KB Output is correct
62 Correct 30 ms 4016 KB Output is correct
63 Correct 30 ms 3932 KB Output is correct
64 Correct 37 ms 3932 KB Output is correct
65 Correct 30 ms 3920 KB Output is correct
66 Correct 30 ms 3920 KB Output is correct
67 Correct 31 ms 3932 KB Output is correct
68 Correct 34 ms 4032 KB Output is correct
69 Correct 30 ms 4012 KB Output is correct
70 Correct 35 ms 3924 KB Output is correct
71 Correct 11 ms 1268 KB Output is correct
72 Correct 11 ms 1116 KB Output is correct
73 Correct 12 ms 1112 KB Output is correct
74 Correct 10 ms 1112 KB Output is correct
75 Correct 11 ms 1048 KB Output is correct
76 Correct 41 ms 2136 KB Output is correct
77 Correct 46 ms 2140 KB Output is correct
78 Correct 41 ms 2220 KB Output is correct
79 Correct 40 ms 2140 KB Output is correct
80 Correct 39 ms 2128 KB Output is correct
81 Correct 135 ms 3932 KB Output is correct
82 Correct 131 ms 3920 KB Output is correct
83 Correct 140 ms 3924 KB Output is correct
84 Correct 135 ms 3968 KB Output is correct
85 Correct 134 ms 3924 KB Output is correct
86 Correct 468 ms 4980 KB Output is correct
87 Correct 446 ms 4816 KB Output is correct
88 Correct 507 ms 5064 KB Output is correct
89 Correct 458 ms 4808 KB Output is correct
90 Correct 486 ms 4812 KB Output is correct
91 Execution timed out 7077 ms 12996 KB Time limit exceeded
92 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 584 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 1372 KB Output is correct
15 Correct 10 ms 2392 KB Output is correct
16 Correct 16 ms 3420 KB Output is correct
17 Correct 14 ms 3420 KB Output is correct
18 Correct 17 ms 3416 KB Output is correct
19 Correct 17 ms 3672 KB Output is correct
20 Correct 19 ms 3416 KB Output is correct
21 Correct 16 ms 3420 KB Output is correct
22 Correct 17 ms 3416 KB Output is correct
23 Correct 17 ms 3308 KB Output is correct
24 Correct 17 ms 3420 KB Output is correct
25 Correct 16 ms 3420 KB Output is correct
26 Correct 0 ms 548 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 6 ms 1368 KB Output is correct
30 Correct 12 ms 2532 KB Output is correct
31 Correct 18 ms 3420 KB Output is correct
32 Correct 18 ms 3596 KB Output is correct
33 Correct 20 ms 3416 KB Output is correct
34 Correct 21 ms 3420 KB Output is correct
35 Correct 19 ms 3592 KB Output is correct
36 Correct 19 ms 3416 KB Output is correct
37 Correct 18 ms 3416 KB Output is correct
38 Correct 18 ms 3416 KB Output is correct
39 Correct 19 ms 3420 KB Output is correct
40 Correct 19 ms 3676 KB Output is correct
41 Correct 0 ms 456 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 5 ms 860 KB Output is correct
48 Correct 6 ms 1112 KB Output is correct
49 Correct 11 ms 1676 KB Output is correct
50 Correct 21 ms 2864 KB Output is correct
51 Correct 34 ms 3932 KB Output is correct
52 Correct 31 ms 3996 KB Output is correct
53 Correct 31 ms 4008 KB Output is correct
54 Correct 30 ms 3932 KB Output is correct
55 Correct 30 ms 4196 KB Output is correct
56 Correct 30 ms 3868 KB Output is correct
57 Correct 30 ms 3920 KB Output is correct
58 Correct 30 ms 3928 KB Output is correct
59 Correct 31 ms 3920 KB Output is correct
60 Correct 32 ms 3924 KB Output is correct
61 Correct 36 ms 3924 KB Output is correct
62 Correct 30 ms 4016 KB Output is correct
63 Correct 30 ms 3932 KB Output is correct
64 Correct 37 ms 3932 KB Output is correct
65 Correct 30 ms 3920 KB Output is correct
66 Correct 30 ms 3920 KB Output is correct
67 Correct 31 ms 3932 KB Output is correct
68 Correct 34 ms 4032 KB Output is correct
69 Correct 30 ms 4012 KB Output is correct
70 Correct 35 ms 3924 KB Output is correct
71 Correct 11 ms 1268 KB Output is correct
72 Correct 11 ms 1116 KB Output is correct
73 Correct 12 ms 1112 KB Output is correct
74 Correct 10 ms 1112 KB Output is correct
75 Correct 11 ms 1048 KB Output is correct
76 Correct 41 ms 2136 KB Output is correct
77 Correct 46 ms 2140 KB Output is correct
78 Correct 41 ms 2220 KB Output is correct
79 Correct 40 ms 2140 KB Output is correct
80 Correct 39 ms 2128 KB Output is correct
81 Correct 135 ms 3932 KB Output is correct
82 Correct 131 ms 3920 KB Output is correct
83 Correct 140 ms 3924 KB Output is correct
84 Correct 135 ms 3968 KB Output is correct
85 Correct 134 ms 3924 KB Output is correct
86 Correct 468 ms 4980 KB Output is correct
87 Correct 446 ms 4816 KB Output is correct
88 Correct 507 ms 5064 KB Output is correct
89 Correct 458 ms 4808 KB Output is correct
90 Correct 486 ms 4812 KB Output is correct
91 Execution timed out 7077 ms 12996 KB Time limit exceeded
92 Halted 0 ms 0 KB -