Submission #588442

# Submission time Handle Problem Language Result Execution time Memory
588442 2022-07-03T09:38:00 Z jasmin Diversity (CEOI21_diversity) C++14
64 / 100
225 ms 30548 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int n, q;
    cin >> n >> q;
    vector<int> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    map<int,int> cnt;
    for(int i=0; i<n; i++){
        cnt[s[i]]++;
    }
    for(int i=0; i<q; i++){
        int a, b;
        cin >> a >> b;
    }

    vector<pair<int,int> > sorted;
    for(auto e: cnt){
        sorted.push_back({e.second, e.first});
    }
    sort(sorted.begin(), sorted.end());

    vector<pair<int,int> > res(cnt.size());
    int l=0; int r=cnt.size()-1; bool left=true;
    for(auto e: sorted){
        int x=e.second; int anz=e.first;
        if(left){
            res[l]={x, anz};
            l++;
            left=false;
        }
        else{
            res[r]={x, anz};
            r--;
            left=true;
        }
    }

    vector<int> neu(n);
    int i=0;
    for(auto e: res){
        int x=e.first;
        int anz=e.second;
        for(int j=0; j<anz; j++, i++){
            neu[i]=x;
        }
    }

    int ans=1;
    int last=1;
    for(int i=1; i<n; i++){
        if(neu[i]==neu[i-1]){
            ans+=last+1;
            last++;
        }
        else{
            ans+=last+i+1;
            last=last+i+1;
        }
    }
    
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 7 ms 2004 KB Output is correct
5 Correct 13 ms 3796 KB Output is correct
6 Correct 21 ms 5652 KB Output is correct
7 Correct 21 ms 5600 KB Output is correct
8 Correct 20 ms 5588 KB Output is correct
9 Correct 20 ms 5616 KB Output is correct
10 Correct 21 ms 5572 KB Output is correct
11 Correct 21 ms 5608 KB Output is correct
12 Correct 22 ms 5584 KB Output is correct
13 Correct 21 ms 5588 KB Output is correct
14 Correct 20 ms 5624 KB Output is correct
15 Correct 22 ms 5624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 7 ms 2004 KB Output is correct
5 Correct 13 ms 3796 KB Output is correct
6 Correct 21 ms 5652 KB Output is correct
7 Correct 21 ms 5600 KB Output is correct
8 Correct 20 ms 5588 KB Output is correct
9 Correct 20 ms 5616 KB Output is correct
10 Correct 21 ms 5572 KB Output is correct
11 Correct 21 ms 5608 KB Output is correct
12 Correct 22 ms 5584 KB Output is correct
13 Correct 21 ms 5588 KB Output is correct
14 Correct 20 ms 5624 KB Output is correct
15 Correct 22 ms 5624 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 272 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 9 ms 2132 KB Output is correct
20 Correct 22 ms 3968 KB Output is correct
21 Correct 24 ms 5736 KB Output is correct
22 Correct 28 ms 5732 KB Output is correct
23 Correct 25 ms 5784 KB Output is correct
24 Correct 24 ms 5712 KB Output is correct
25 Correct 37 ms 5756 KB Output is correct
26 Correct 26 ms 5732 KB Output is correct
27 Correct 24 ms 5708 KB Output is correct
28 Correct 24 ms 5696 KB Output is correct
29 Correct 25 ms 5708 KB Output is correct
30 Correct 25 ms 5776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 7 ms 2004 KB Output is correct
5 Correct 13 ms 3796 KB Output is correct
6 Correct 21 ms 5652 KB Output is correct
7 Correct 21 ms 5600 KB Output is correct
8 Correct 20 ms 5588 KB Output is correct
9 Correct 20 ms 5616 KB Output is correct
10 Correct 21 ms 5572 KB Output is correct
11 Correct 21 ms 5608 KB Output is correct
12 Correct 22 ms 5584 KB Output is correct
13 Correct 21 ms 5588 KB Output is correct
14 Correct 20 ms 5624 KB Output is correct
15 Correct 22 ms 5624 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 272 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 9 ms 2132 KB Output is correct
20 Correct 22 ms 3968 KB Output is correct
21 Correct 24 ms 5736 KB Output is correct
22 Correct 28 ms 5732 KB Output is correct
23 Correct 25 ms 5784 KB Output is correct
24 Correct 24 ms 5712 KB Output is correct
25 Correct 37 ms 5756 KB Output is correct
26 Correct 26 ms 5732 KB Output is correct
27 Correct 24 ms 5708 KB Output is correct
28 Correct 24 ms 5696 KB Output is correct
29 Correct 25 ms 5708 KB Output is correct
30 Correct 25 ms 5776 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 440 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 2 ms 596 KB Output is correct
37 Correct 10 ms 1236 KB Output is correct
38 Correct 8 ms 1300 KB Output is correct
39 Correct 14 ms 2388 KB Output is correct
40 Correct 41 ms 4304 KB Output is correct
41 Correct 56 ms 6248 KB Output is correct
42 Correct 39 ms 6252 KB Output is correct
43 Correct 37 ms 6248 KB Output is correct
44 Correct 38 ms 6220 KB Output is correct
45 Correct 37 ms 6252 KB Output is correct
46 Correct 36 ms 6188 KB Output is correct
47 Correct 39 ms 6168 KB Output is correct
48 Correct 38 ms 6252 KB Output is correct
49 Correct 37 ms 6180 KB Output is correct
50 Correct 36 ms 6248 KB Output is correct
51 Correct 37 ms 6232 KB Output is correct
52 Correct 37 ms 6232 KB Output is correct
53 Correct 52 ms 6176 KB Output is correct
54 Correct 37 ms 6216 KB Output is correct
55 Correct 37 ms 6180 KB Output is correct
56 Correct 36 ms 6220 KB Output is correct
57 Correct 40 ms 6244 KB Output is correct
58 Correct 42 ms 6252 KB Output is correct
59 Correct 37 ms 6188 KB Output is correct
60 Correct 36 ms 6232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 7 ms 2004 KB Output is correct
15 Correct 13 ms 3796 KB Output is correct
16 Correct 21 ms 5652 KB Output is correct
17 Correct 21 ms 5600 KB Output is correct
18 Correct 20 ms 5588 KB Output is correct
19 Correct 20 ms 5616 KB Output is correct
20 Correct 21 ms 5572 KB Output is correct
21 Correct 21 ms 5608 KB Output is correct
22 Correct 22 ms 5584 KB Output is correct
23 Correct 21 ms 5588 KB Output is correct
24 Correct 20 ms 5624 KB Output is correct
25 Correct 22 ms 5624 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 272 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 9 ms 2132 KB Output is correct
30 Correct 22 ms 3968 KB Output is correct
31 Correct 24 ms 5736 KB Output is correct
32 Correct 28 ms 5732 KB Output is correct
33 Correct 25 ms 5784 KB Output is correct
34 Correct 24 ms 5712 KB Output is correct
35 Correct 37 ms 5756 KB Output is correct
36 Correct 26 ms 5732 KB Output is correct
37 Correct 24 ms 5708 KB Output is correct
38 Correct 24 ms 5696 KB Output is correct
39 Correct 25 ms 5708 KB Output is correct
40 Correct 25 ms 5776 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 2 ms 440 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 10 ms 1236 KB Output is correct
48 Correct 8 ms 1300 KB Output is correct
49 Correct 14 ms 2388 KB Output is correct
50 Correct 41 ms 4304 KB Output is correct
51 Correct 56 ms 6248 KB Output is correct
52 Correct 39 ms 6252 KB Output is correct
53 Correct 37 ms 6248 KB Output is correct
54 Correct 38 ms 6220 KB Output is correct
55 Correct 37 ms 6252 KB Output is correct
56 Correct 36 ms 6188 KB Output is correct
57 Correct 39 ms 6168 KB Output is correct
58 Correct 38 ms 6252 KB Output is correct
59 Correct 37 ms 6180 KB Output is correct
60 Correct 36 ms 6248 KB Output is correct
61 Correct 37 ms 6232 KB Output is correct
62 Correct 37 ms 6232 KB Output is correct
63 Correct 52 ms 6176 KB Output is correct
64 Correct 37 ms 6216 KB Output is correct
65 Correct 37 ms 6180 KB Output is correct
66 Correct 36 ms 6220 KB Output is correct
67 Correct 40 ms 6244 KB Output is correct
68 Correct 42 ms 6252 KB Output is correct
69 Correct 37 ms 6188 KB Output is correct
70 Correct 36 ms 6232 KB Output is correct
71 Correct 8 ms 1492 KB Output is correct
72 Correct 8 ms 1492 KB Output is correct
73 Correct 7 ms 1492 KB Output is correct
74 Correct 8 ms 1448 KB Output is correct
75 Correct 8 ms 1460 KB Output is correct
76 Correct 17 ms 2868 KB Output is correct
77 Correct 18 ms 2784 KB Output is correct
78 Correct 17 ms 2764 KB Output is correct
79 Correct 17 ms 2772 KB Output is correct
80 Correct 20 ms 2892 KB Output is correct
81 Correct 37 ms 5552 KB Output is correct
82 Correct 37 ms 5420 KB Output is correct
83 Correct 37 ms 5372 KB Output is correct
84 Correct 37 ms 5372 KB Output is correct
85 Correct 37 ms 5464 KB Output is correct
86 Correct 45 ms 6472 KB Output is correct
87 Correct 49 ms 6468 KB Output is correct
88 Correct 46 ms 6524 KB Output is correct
89 Correct 46 ms 6480 KB Output is correct
90 Correct 45 ms 6408 KB Output is correct
91 Correct 112 ms 16260 KB Output is correct
92 Correct 118 ms 16200 KB Output is correct
93 Correct 123 ms 16288 KB Output is correct
94 Correct 116 ms 16208 KB Output is correct
95 Correct 114 ms 16228 KB Output is correct
96 Correct 181 ms 25800 KB Output is correct
97 Correct 188 ms 26028 KB Output is correct
98 Correct 211 ms 25804 KB Output is correct
99 Correct 190 ms 25812 KB Output is correct
100 Correct 191 ms 25760 KB Output is correct
101 Correct 202 ms 25716 KB Output is correct
102 Correct 184 ms 25804 KB Output is correct
103 Correct 188 ms 25800 KB Output is correct
104 Correct 187 ms 25804 KB Output is correct
105 Correct 187 ms 25812 KB Output is correct
106 Correct 212 ms 30428 KB Output is correct
107 Correct 219 ms 30540 KB Output is correct
108 Correct 221 ms 30524 KB Output is correct
109 Correct 216 ms 30548 KB Output is correct
110 Correct 225 ms 30472 KB Output is correct
111 Correct 208 ms 30548 KB Output is correct
112 Correct 215 ms 30536 KB Output is correct
113 Correct 218 ms 30432 KB Output is correct
114 Correct 217 ms 30492 KB Output is correct
115 Correct 209 ms 30516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 7 ms 2004 KB Output is correct
15 Correct 13 ms 3796 KB Output is correct
16 Correct 21 ms 5652 KB Output is correct
17 Correct 21 ms 5600 KB Output is correct
18 Correct 20 ms 5588 KB Output is correct
19 Correct 20 ms 5616 KB Output is correct
20 Correct 21 ms 5572 KB Output is correct
21 Correct 21 ms 5608 KB Output is correct
22 Correct 22 ms 5584 KB Output is correct
23 Correct 21 ms 5588 KB Output is correct
24 Correct 20 ms 5624 KB Output is correct
25 Correct 22 ms 5624 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 272 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 9 ms 2132 KB Output is correct
30 Correct 22 ms 3968 KB Output is correct
31 Correct 24 ms 5736 KB Output is correct
32 Correct 28 ms 5732 KB Output is correct
33 Correct 25 ms 5784 KB Output is correct
34 Correct 24 ms 5712 KB Output is correct
35 Correct 37 ms 5756 KB Output is correct
36 Correct 26 ms 5732 KB Output is correct
37 Correct 24 ms 5708 KB Output is correct
38 Correct 24 ms 5696 KB Output is correct
39 Correct 25 ms 5708 KB Output is correct
40 Correct 25 ms 5776 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 2 ms 440 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 10 ms 1236 KB Output is correct
48 Correct 8 ms 1300 KB Output is correct
49 Correct 14 ms 2388 KB Output is correct
50 Correct 41 ms 4304 KB Output is correct
51 Correct 56 ms 6248 KB Output is correct
52 Correct 39 ms 6252 KB Output is correct
53 Correct 37 ms 6248 KB Output is correct
54 Correct 38 ms 6220 KB Output is correct
55 Correct 37 ms 6252 KB Output is correct
56 Correct 36 ms 6188 KB Output is correct
57 Correct 39 ms 6168 KB Output is correct
58 Correct 38 ms 6252 KB Output is correct
59 Correct 37 ms 6180 KB Output is correct
60 Correct 36 ms 6248 KB Output is correct
61 Correct 37 ms 6232 KB Output is correct
62 Correct 37 ms 6232 KB Output is correct
63 Correct 52 ms 6176 KB Output is correct
64 Correct 37 ms 6216 KB Output is correct
65 Correct 37 ms 6180 KB Output is correct
66 Correct 36 ms 6220 KB Output is correct
67 Correct 40 ms 6244 KB Output is correct
68 Correct 42 ms 6252 KB Output is correct
69 Correct 37 ms 6188 KB Output is correct
70 Correct 36 ms 6232 KB Output is correct
71 Correct 8 ms 1492 KB Output is correct
72 Correct 8 ms 1492 KB Output is correct
73 Correct 7 ms 1492 KB Output is correct
74 Correct 8 ms 1448 KB Output is correct
75 Correct 8 ms 1460 KB Output is correct
76 Correct 17 ms 2868 KB Output is correct
77 Correct 18 ms 2784 KB Output is correct
78 Correct 17 ms 2764 KB Output is correct
79 Correct 17 ms 2772 KB Output is correct
80 Correct 20 ms 2892 KB Output is correct
81 Correct 37 ms 5552 KB Output is correct
82 Correct 37 ms 5420 KB Output is correct
83 Correct 37 ms 5372 KB Output is correct
84 Correct 37 ms 5372 KB Output is correct
85 Correct 37 ms 5464 KB Output is correct
86 Correct 45 ms 6472 KB Output is correct
87 Correct 49 ms 6468 KB Output is correct
88 Correct 46 ms 6524 KB Output is correct
89 Correct 46 ms 6480 KB Output is correct
90 Correct 45 ms 6408 KB Output is correct
91 Correct 112 ms 16260 KB Output is correct
92 Correct 118 ms 16200 KB Output is correct
93 Correct 123 ms 16288 KB Output is correct
94 Correct 116 ms 16208 KB Output is correct
95 Correct 114 ms 16228 KB Output is correct
96 Correct 181 ms 25800 KB Output is correct
97 Correct 188 ms 26028 KB Output is correct
98 Correct 211 ms 25804 KB Output is correct
99 Correct 190 ms 25812 KB Output is correct
100 Correct 191 ms 25760 KB Output is correct
101 Correct 202 ms 25716 KB Output is correct
102 Correct 184 ms 25804 KB Output is correct
103 Correct 188 ms 25800 KB Output is correct
104 Correct 187 ms 25804 KB Output is correct
105 Correct 187 ms 25812 KB Output is correct
106 Correct 212 ms 30428 KB Output is correct
107 Correct 219 ms 30540 KB Output is correct
108 Correct 221 ms 30524 KB Output is correct
109 Correct 216 ms 30548 KB Output is correct
110 Correct 225 ms 30472 KB Output is correct
111 Correct 208 ms 30548 KB Output is correct
112 Correct 215 ms 30536 KB Output is correct
113 Correct 218 ms 30432 KB Output is correct
114 Correct 217 ms 30492 KB Output is correct
115 Correct 209 ms 30516 KB Output is correct
116 Incorrect 7 ms 904 KB Output isn't correct
117 Halted 0 ms 0 KB -