Submission #786048

# Submission time Handle Problem Language Result Execution time Memory
786048 2023-07-17T23:55:50 Z Ozy Diversity (CEOI21_diversity) C++17
64 / 100
39 ms 10568 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)

#define MAX 300000

lli n,a,res,q;
lli arr[MAX+2],vis[MAX+2];
vector<lli> frec;
deque<lli> orden;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> q;
    rep(i,1,n) {
        cin >> arr[i];
        vis[arr[i]]++;
    }
    rep(i,1,n) {
        if (vis[i] == 0) continue;
        frec.push_back(vis[i]);
        vis[i] = 0;
    }
    sort(frec.begin(), frec.end());
    reverse(frec.begin(), frec.end());
    lli x = 0;
    for(auto act : frec) {
        if (x) orden.push_back(act);
        else orden.push_front(act);
        x ^= 1;
    }

    //lee la pregunta
    lli y;
    cin >> x >> y;

    lli sum = 0;
    lli act,glob = 0;
    while (!orden.empty()) {
        act = orden.front();
        orden.pop_front();

        res += glob*act;

        x = act*(act+1)/2;
        res += x;

        sum += act;
        glob += sum + act;
    }


    cout << res;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 6 ms 1236 KB Output is correct
5 Correct 9 ms 2260 KB Output is correct
6 Correct 14 ms 3340 KB Output is correct
7 Correct 13 ms 3160 KB Output is correct
8 Correct 13 ms 3284 KB Output is correct
9 Correct 13 ms 3304 KB Output is correct
10 Correct 14 ms 3268 KB Output is correct
11 Correct 14 ms 3248 KB Output is correct
12 Correct 17 ms 3284 KB Output is correct
13 Correct 14 ms 3296 KB Output is correct
14 Correct 15 ms 3312 KB Output is correct
15 Correct 15 ms 3256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 6 ms 1236 KB Output is correct
5 Correct 9 ms 2260 KB Output is correct
6 Correct 14 ms 3340 KB Output is correct
7 Correct 13 ms 3160 KB Output is correct
8 Correct 13 ms 3284 KB Output is correct
9 Correct 13 ms 3304 KB Output is correct
10 Correct 14 ms 3268 KB Output is correct
11 Correct 14 ms 3248 KB Output is correct
12 Correct 17 ms 3284 KB Output is correct
13 Correct 14 ms 3296 KB Output is correct
14 Correct 15 ms 3312 KB Output is correct
15 Correct 15 ms 3256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 6 ms 1364 KB Output is correct
20 Correct 10 ms 2388 KB Output is correct
21 Correct 14 ms 3412 KB Output is correct
22 Correct 14 ms 3356 KB Output is correct
23 Correct 15 ms 3452 KB Output is correct
24 Correct 20 ms 3420 KB Output is correct
25 Correct 14 ms 3396 KB Output is correct
26 Correct 15 ms 3372 KB Output is correct
27 Correct 19 ms 3440 KB Output is correct
28 Correct 18 ms 3320 KB Output is correct
29 Correct 15 ms 3396 KB Output is correct
30 Correct 14 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 6 ms 1236 KB Output is correct
5 Correct 9 ms 2260 KB Output is correct
6 Correct 14 ms 3340 KB Output is correct
7 Correct 13 ms 3160 KB Output is correct
8 Correct 13 ms 3284 KB Output is correct
9 Correct 13 ms 3304 KB Output is correct
10 Correct 14 ms 3268 KB Output is correct
11 Correct 14 ms 3248 KB Output is correct
12 Correct 17 ms 3284 KB Output is correct
13 Correct 14 ms 3296 KB Output is correct
14 Correct 15 ms 3312 KB Output is correct
15 Correct 15 ms 3256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 6 ms 1364 KB Output is correct
20 Correct 10 ms 2388 KB Output is correct
21 Correct 14 ms 3412 KB Output is correct
22 Correct 14 ms 3356 KB Output is correct
23 Correct 15 ms 3452 KB Output is correct
24 Correct 20 ms 3420 KB Output is correct
25 Correct 14 ms 3396 KB Output is correct
26 Correct 15 ms 3372 KB Output is correct
27 Correct 19 ms 3440 KB Output is correct
28 Correct 18 ms 3320 KB Output is correct
29 Correct 15 ms 3396 KB Output is correct
30 Correct 14 ms 3436 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 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 3 ms 852 KB Output is correct
39 Correct 6 ms 1492 KB Output is correct
40 Correct 15 ms 2792 KB Output is correct
41 Correct 16 ms 3736 KB Output is correct
42 Correct 16 ms 3760 KB Output is correct
43 Correct 20 ms 3796 KB Output is correct
44 Correct 16 ms 3796 KB Output is correct
45 Correct 18 ms 3736 KB Output is correct
46 Correct 15 ms 3796 KB Output is correct
47 Correct 16 ms 3768 KB Output is correct
48 Correct 16 ms 3776 KB Output is correct
49 Correct 16 ms 3784 KB Output is correct
50 Correct 20 ms 3768 KB Output is correct
51 Correct 21 ms 3788 KB Output is correct
52 Correct 16 ms 3796 KB Output is correct
53 Correct 16 ms 3836 KB Output is correct
54 Correct 16 ms 3856 KB Output is correct
55 Correct 15 ms 3756 KB Output is correct
56 Correct 16 ms 3744 KB Output is correct
57 Correct 16 ms 3748 KB Output is correct
58 Correct 16 ms 3800 KB Output is correct
59 Correct 16 ms 3812 KB Output is correct
60 Correct 17 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 6 ms 1236 KB Output is correct
15 Correct 9 ms 2260 KB Output is correct
16 Correct 14 ms 3340 KB Output is correct
17 Correct 13 ms 3160 KB Output is correct
18 Correct 13 ms 3284 KB Output is correct
19 Correct 13 ms 3304 KB Output is correct
20 Correct 14 ms 3268 KB Output is correct
21 Correct 14 ms 3248 KB Output is correct
22 Correct 17 ms 3284 KB Output is correct
23 Correct 14 ms 3296 KB Output is correct
24 Correct 15 ms 3312 KB Output is correct
25 Correct 15 ms 3256 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 6 ms 1364 KB Output is correct
30 Correct 10 ms 2388 KB Output is correct
31 Correct 14 ms 3412 KB Output is correct
32 Correct 14 ms 3356 KB Output is correct
33 Correct 15 ms 3452 KB Output is correct
34 Correct 20 ms 3420 KB Output is correct
35 Correct 14 ms 3396 KB Output is correct
36 Correct 15 ms 3372 KB Output is correct
37 Correct 19 ms 3440 KB Output is correct
38 Correct 18 ms 3320 KB Output is correct
39 Correct 15 ms 3396 KB Output is correct
40 Correct 14 ms 3436 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 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 3 ms 852 KB Output is correct
48 Correct 3 ms 852 KB Output is correct
49 Correct 6 ms 1492 KB Output is correct
50 Correct 15 ms 2792 KB Output is correct
51 Correct 16 ms 3736 KB Output is correct
52 Correct 16 ms 3760 KB Output is correct
53 Correct 20 ms 3796 KB Output is correct
54 Correct 16 ms 3796 KB Output is correct
55 Correct 18 ms 3736 KB Output is correct
56 Correct 15 ms 3796 KB Output is correct
57 Correct 16 ms 3768 KB Output is correct
58 Correct 16 ms 3776 KB Output is correct
59 Correct 16 ms 3784 KB Output is correct
60 Correct 20 ms 3768 KB Output is correct
61 Correct 21 ms 3788 KB Output is correct
62 Correct 16 ms 3796 KB Output is correct
63 Correct 16 ms 3836 KB Output is correct
64 Correct 16 ms 3856 KB Output is correct
65 Correct 15 ms 3756 KB Output is correct
66 Correct 16 ms 3744 KB Output is correct
67 Correct 16 ms 3748 KB Output is correct
68 Correct 16 ms 3800 KB Output is correct
69 Correct 16 ms 3812 KB Output is correct
70 Correct 17 ms 3796 KB Output is correct
71 Correct 3 ms 980 KB Output is correct
72 Correct 4 ms 988 KB Output is correct
73 Correct 4 ms 904 KB Output is correct
74 Correct 5 ms 980 KB Output is correct
75 Correct 3 ms 980 KB Output is correct
76 Correct 7 ms 1684 KB Output is correct
77 Correct 6 ms 1684 KB Output is correct
78 Correct 7 ms 1620 KB Output is correct
79 Correct 6 ms 1620 KB Output is correct
80 Correct 6 ms 1744 KB Output is correct
81 Correct 13 ms 3028 KB Output is correct
82 Correct 12 ms 3044 KB Output is correct
83 Correct 12 ms 3028 KB Output is correct
84 Correct 12 ms 3116 KB Output is correct
85 Correct 12 ms 3120 KB Output is correct
86 Correct 14 ms 3412 KB Output is correct
87 Correct 16 ms 3436 KB Output is correct
88 Correct 14 ms 3468 KB Output is correct
89 Correct 15 ms 3500 KB Output is correct
90 Correct 14 ms 3468 KB Output is correct
91 Correct 24 ms 6700 KB Output is correct
92 Correct 23 ms 6736 KB Output is correct
93 Correct 23 ms 6700 KB Output is correct
94 Correct 26 ms 6796 KB Output is correct
95 Correct 23 ms 6736 KB Output is correct
96 Correct 28 ms 9280 KB Output is correct
97 Correct 28 ms 9252 KB Output is correct
98 Correct 29 ms 9340 KB Output is correct
99 Correct 28 ms 9284 KB Output is correct
100 Correct 28 ms 9248 KB Output is correct
101 Correct 29 ms 9304 KB Output is correct
102 Correct 28 ms 9284 KB Output is correct
103 Correct 28 ms 9312 KB Output is correct
104 Correct 30 ms 9284 KB Output is correct
105 Correct 29 ms 9296 KB Output is correct
106 Correct 29 ms 10440 KB Output is correct
107 Correct 28 ms 10548 KB Output is correct
108 Correct 29 ms 10568 KB Output is correct
109 Correct 29 ms 10560 KB Output is correct
110 Correct 31 ms 10564 KB Output is correct
111 Correct 31 ms 10536 KB Output is correct
112 Correct 29 ms 10472 KB Output is correct
113 Correct 39 ms 10564 KB Output is correct
114 Correct 30 ms 10520 KB Output is correct
115 Correct 28 ms 10496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 6 ms 1236 KB Output is correct
15 Correct 9 ms 2260 KB Output is correct
16 Correct 14 ms 3340 KB Output is correct
17 Correct 13 ms 3160 KB Output is correct
18 Correct 13 ms 3284 KB Output is correct
19 Correct 13 ms 3304 KB Output is correct
20 Correct 14 ms 3268 KB Output is correct
21 Correct 14 ms 3248 KB Output is correct
22 Correct 17 ms 3284 KB Output is correct
23 Correct 14 ms 3296 KB Output is correct
24 Correct 15 ms 3312 KB Output is correct
25 Correct 15 ms 3256 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 6 ms 1364 KB Output is correct
30 Correct 10 ms 2388 KB Output is correct
31 Correct 14 ms 3412 KB Output is correct
32 Correct 14 ms 3356 KB Output is correct
33 Correct 15 ms 3452 KB Output is correct
34 Correct 20 ms 3420 KB Output is correct
35 Correct 14 ms 3396 KB Output is correct
36 Correct 15 ms 3372 KB Output is correct
37 Correct 19 ms 3440 KB Output is correct
38 Correct 18 ms 3320 KB Output is correct
39 Correct 15 ms 3396 KB Output is correct
40 Correct 14 ms 3436 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 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 3 ms 852 KB Output is correct
48 Correct 3 ms 852 KB Output is correct
49 Correct 6 ms 1492 KB Output is correct
50 Correct 15 ms 2792 KB Output is correct
51 Correct 16 ms 3736 KB Output is correct
52 Correct 16 ms 3760 KB Output is correct
53 Correct 20 ms 3796 KB Output is correct
54 Correct 16 ms 3796 KB Output is correct
55 Correct 18 ms 3736 KB Output is correct
56 Correct 15 ms 3796 KB Output is correct
57 Correct 16 ms 3768 KB Output is correct
58 Correct 16 ms 3776 KB Output is correct
59 Correct 16 ms 3784 KB Output is correct
60 Correct 20 ms 3768 KB Output is correct
61 Correct 21 ms 3788 KB Output is correct
62 Correct 16 ms 3796 KB Output is correct
63 Correct 16 ms 3836 KB Output is correct
64 Correct 16 ms 3856 KB Output is correct
65 Correct 15 ms 3756 KB Output is correct
66 Correct 16 ms 3744 KB Output is correct
67 Correct 16 ms 3748 KB Output is correct
68 Correct 16 ms 3800 KB Output is correct
69 Correct 16 ms 3812 KB Output is correct
70 Correct 17 ms 3796 KB Output is correct
71 Correct 3 ms 980 KB Output is correct
72 Correct 4 ms 988 KB Output is correct
73 Correct 4 ms 904 KB Output is correct
74 Correct 5 ms 980 KB Output is correct
75 Correct 3 ms 980 KB Output is correct
76 Correct 7 ms 1684 KB Output is correct
77 Correct 6 ms 1684 KB Output is correct
78 Correct 7 ms 1620 KB Output is correct
79 Correct 6 ms 1620 KB Output is correct
80 Correct 6 ms 1744 KB Output is correct
81 Correct 13 ms 3028 KB Output is correct
82 Correct 12 ms 3044 KB Output is correct
83 Correct 12 ms 3028 KB Output is correct
84 Correct 12 ms 3116 KB Output is correct
85 Correct 12 ms 3120 KB Output is correct
86 Correct 14 ms 3412 KB Output is correct
87 Correct 16 ms 3436 KB Output is correct
88 Correct 14 ms 3468 KB Output is correct
89 Correct 15 ms 3500 KB Output is correct
90 Correct 14 ms 3468 KB Output is correct
91 Correct 24 ms 6700 KB Output is correct
92 Correct 23 ms 6736 KB Output is correct
93 Correct 23 ms 6700 KB Output is correct
94 Correct 26 ms 6796 KB Output is correct
95 Correct 23 ms 6736 KB Output is correct
96 Correct 28 ms 9280 KB Output is correct
97 Correct 28 ms 9252 KB Output is correct
98 Correct 29 ms 9340 KB Output is correct
99 Correct 28 ms 9284 KB Output is correct
100 Correct 28 ms 9248 KB Output is correct
101 Correct 29 ms 9304 KB Output is correct
102 Correct 28 ms 9284 KB Output is correct
103 Correct 28 ms 9312 KB Output is correct
104 Correct 30 ms 9284 KB Output is correct
105 Correct 29 ms 9296 KB Output is correct
106 Correct 29 ms 10440 KB Output is correct
107 Correct 28 ms 10548 KB Output is correct
108 Correct 29 ms 10568 KB Output is correct
109 Correct 29 ms 10560 KB Output is correct
110 Correct 31 ms 10564 KB Output is correct
111 Correct 31 ms 10536 KB Output is correct
112 Correct 29 ms 10472 KB Output is correct
113 Correct 39 ms 10564 KB Output is correct
114 Correct 30 ms 10520 KB Output is correct
115 Correct 28 ms 10496 KB Output is correct
116 Incorrect 1 ms 468 KB Output isn't correct
117 Halted 0 ms 0 KB -