Submission #1097436

# Submission time Handle Problem Language Result Execution time Memory
1097436 2024-10-07T11:26:40 Z alexander707070 Diversity (CEOI21_diversity) C++17
38 / 100
7000 ms 4948 KB
#include<bits/stdc++.h>
#define MAXN 300007
using namespace std;

int n,a[MAXN],q;

int br[MAXN],maxs,l,r,p[MAXN],len;
long long ans;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>q;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        br[a[i]]++;

        maxs=max(maxs,a[i]);
    }

    sort(br+1,br+maxs+1);
    for(int i=1;i<=maxs;i++){
        if(br[i]>0)r++;
    }
    r++;
    len=r-1;

    for(int i=1;i<=maxs;i++){
        if(br[i]==0)continue;

        if(i%2==0){
            l++; p[l]=br[i];
        }else{
            r--; p[r]=br[i];
        }
    }

    for(int i=1;i<=len;i++){
        ans+=(long long) (p[i])*(p[i]-1)/2+p[i];
    }

    for(int i=1;i<=len;i++){
        for(int f=i+1;f<=len;f++){
            ans+=(long long) p[i]*p[f]*(f-i+1);
        }
    }

    cout<<ans<<"\n";
    
    return 0;
}
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 348 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 1 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 8 ms 1516 KB Output is correct
6 Correct 12 ms 2140 KB Output is correct
7 Correct 11 ms 2004 KB Output is correct
8 Correct 12 ms 2140 KB Output is correct
9 Correct 12 ms 2140 KB Output is correct
10 Correct 11 ms 2140 KB Output is correct
11 Correct 11 ms 2140 KB Output is correct
12 Correct 11 ms 2140 KB Output is correct
13 Correct 11 ms 2124 KB Output is correct
14 Correct 11 ms 2140 KB Output is correct
15 Correct 11 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 8 ms 1516 KB Output is correct
6 Correct 12 ms 2140 KB Output is correct
7 Correct 11 ms 2004 KB Output is correct
8 Correct 12 ms 2140 KB Output is correct
9 Correct 12 ms 2140 KB Output is correct
10 Correct 11 ms 2140 KB Output is correct
11 Correct 11 ms 2140 KB Output is correct
12 Correct 11 ms 2140 KB Output is correct
13 Correct 11 ms 2124 KB Output is correct
14 Correct 11 ms 2140 KB Output is correct
15 Correct 11 ms 2140 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 1116 KB Output is correct
20 Correct 8 ms 1640 KB Output is correct
21 Correct 12 ms 2396 KB Output is correct
22 Correct 12 ms 2396 KB Output is correct
23 Correct 12 ms 2396 KB Output is correct
24 Correct 12 ms 2304 KB Output is correct
25 Correct 12 ms 2396 KB Output is correct
26 Correct 12 ms 2316 KB Output is correct
27 Correct 12 ms 2396 KB Output is correct
28 Correct 12 ms 2140 KB Output is correct
29 Correct 12 ms 2140 KB Output is correct
30 Correct 12 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 8 ms 1516 KB Output is correct
6 Correct 12 ms 2140 KB Output is correct
7 Correct 11 ms 2004 KB Output is correct
8 Correct 12 ms 2140 KB Output is correct
9 Correct 12 ms 2140 KB Output is correct
10 Correct 11 ms 2140 KB Output is correct
11 Correct 11 ms 2140 KB Output is correct
12 Correct 11 ms 2140 KB Output is correct
13 Correct 11 ms 2124 KB Output is correct
14 Correct 11 ms 2140 KB Output is correct
15 Correct 11 ms 2140 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 1116 KB Output is correct
20 Correct 8 ms 1640 KB Output is correct
21 Correct 12 ms 2396 KB Output is correct
22 Correct 12 ms 2396 KB Output is correct
23 Correct 12 ms 2396 KB Output is correct
24 Correct 12 ms 2304 KB Output is correct
25 Correct 12 ms 2396 KB Output is correct
26 Correct 12 ms 2316 KB Output is correct
27 Correct 12 ms 2396 KB Output is correct
28 Correct 12 ms 2140 KB Output is correct
29 Correct 12 ms 2140 KB Output is correct
30 Correct 12 ms 2396 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 472 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 3 ms 860 KB Output is correct
39 Correct 5 ms 1112 KB Output is correct
40 Correct 9 ms 1884 KB Output is correct
41 Correct 13 ms 2616 KB Output is correct
42 Correct 14 ms 2652 KB Output is correct
43 Correct 14 ms 2652 KB Output is correct
44 Correct 16 ms 2652 KB Output is correct
45 Correct 13 ms 2780 KB Output is correct
46 Correct 14 ms 2652 KB Output is correct
47 Correct 13 ms 2800 KB Output is correct
48 Correct 16 ms 2652 KB Output is correct
49 Correct 20 ms 2652 KB Output is correct
50 Correct 14 ms 2648 KB Output is correct
51 Correct 14 ms 2656 KB Output is correct
52 Correct 13 ms 2572 KB Output is correct
53 Correct 14 ms 2652 KB Output is correct
54 Correct 13 ms 2616 KB Output is correct
55 Correct 14 ms 2652 KB Output is correct
56 Correct 13 ms 2652 KB Output is correct
57 Correct 14 ms 2652 KB Output is correct
58 Correct 16 ms 2776 KB Output is correct
59 Correct 13 ms 2652 KB Output is correct
60 Correct 13 ms 2604 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 348 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 1 ms 348 KB Output is correct
12 Correct 0 ms 464 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 4 ms 856 KB Output is correct
15 Correct 8 ms 1516 KB Output is correct
16 Correct 12 ms 2140 KB Output is correct
17 Correct 11 ms 2004 KB Output is correct
18 Correct 12 ms 2140 KB Output is correct
19 Correct 12 ms 2140 KB Output is correct
20 Correct 11 ms 2140 KB Output is correct
21 Correct 11 ms 2140 KB Output is correct
22 Correct 11 ms 2140 KB Output is correct
23 Correct 11 ms 2124 KB Output is correct
24 Correct 11 ms 2140 KB Output is correct
25 Correct 11 ms 2140 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 4 ms 1116 KB Output is correct
30 Correct 8 ms 1640 KB Output is correct
31 Correct 12 ms 2396 KB Output is correct
32 Correct 12 ms 2396 KB Output is correct
33 Correct 12 ms 2396 KB Output is correct
34 Correct 12 ms 2304 KB Output is correct
35 Correct 12 ms 2396 KB Output is correct
36 Correct 12 ms 2316 KB Output is correct
37 Correct 12 ms 2396 KB Output is correct
38 Correct 12 ms 2140 KB Output is correct
39 Correct 12 ms 2140 KB Output is correct
40 Correct 12 ms 2396 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 472 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
48 Correct 3 ms 860 KB Output is correct
49 Correct 5 ms 1112 KB Output is correct
50 Correct 9 ms 1884 KB Output is correct
51 Correct 13 ms 2616 KB Output is correct
52 Correct 14 ms 2652 KB Output is correct
53 Correct 14 ms 2652 KB Output is correct
54 Correct 16 ms 2652 KB Output is correct
55 Correct 13 ms 2780 KB Output is correct
56 Correct 14 ms 2652 KB Output is correct
57 Correct 13 ms 2800 KB Output is correct
58 Correct 16 ms 2652 KB Output is correct
59 Correct 20 ms 2652 KB Output is correct
60 Correct 14 ms 2648 KB Output is correct
61 Correct 14 ms 2656 KB Output is correct
62 Correct 13 ms 2572 KB Output is correct
63 Correct 14 ms 2652 KB Output is correct
64 Correct 13 ms 2616 KB Output is correct
65 Correct 14 ms 2652 KB Output is correct
66 Correct 13 ms 2652 KB Output is correct
67 Correct 14 ms 2652 KB Output is correct
68 Correct 16 ms 2776 KB Output is correct
69 Correct 13 ms 2652 KB Output is correct
70 Correct 13 ms 2604 KB Output is correct
71 Correct 5 ms 860 KB Output is correct
72 Correct 4 ms 908 KB Output is correct
73 Correct 4 ms 856 KB Output is correct
74 Correct 4 ms 860 KB Output is correct
75 Correct 4 ms 860 KB Output is correct
76 Correct 14 ms 1372 KB Output is correct
77 Correct 14 ms 1372 KB Output is correct
78 Correct 16 ms 1372 KB Output is correct
79 Correct 13 ms 1372 KB Output is correct
80 Correct 13 ms 1376 KB Output is correct
81 Correct 44 ms 2140 KB Output is correct
82 Correct 44 ms 2248 KB Output is correct
83 Correct 44 ms 2136 KB Output is correct
84 Correct 44 ms 2392 KB Output is correct
85 Correct 44 ms 2276 KB Output is correct
86 Correct 143 ms 2396 KB Output is correct
87 Correct 146 ms 2244 KB Output is correct
88 Correct 143 ms 2448 KB Output is correct
89 Correct 141 ms 2392 KB Output is correct
90 Correct 143 ms 2396 KB Output is correct
91 Correct 3334 ms 3924 KB Output is correct
92 Correct 3324 ms 4136 KB Output is correct
93 Correct 3294 ms 4136 KB Output is correct
94 Correct 3309 ms 4136 KB Output is correct
95 Correct 3321 ms 4144 KB Output is correct
96 Execution timed out 7049 ms 4948 KB Time limit exceeded
97 Halted 0 ms 0 KB -
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 348 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 1 ms 348 KB Output is correct
12 Correct 0 ms 464 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 4 ms 856 KB Output is correct
15 Correct 8 ms 1516 KB Output is correct
16 Correct 12 ms 2140 KB Output is correct
17 Correct 11 ms 2004 KB Output is correct
18 Correct 12 ms 2140 KB Output is correct
19 Correct 12 ms 2140 KB Output is correct
20 Correct 11 ms 2140 KB Output is correct
21 Correct 11 ms 2140 KB Output is correct
22 Correct 11 ms 2140 KB Output is correct
23 Correct 11 ms 2124 KB Output is correct
24 Correct 11 ms 2140 KB Output is correct
25 Correct 11 ms 2140 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 4 ms 1116 KB Output is correct
30 Correct 8 ms 1640 KB Output is correct
31 Correct 12 ms 2396 KB Output is correct
32 Correct 12 ms 2396 KB Output is correct
33 Correct 12 ms 2396 KB Output is correct
34 Correct 12 ms 2304 KB Output is correct
35 Correct 12 ms 2396 KB Output is correct
36 Correct 12 ms 2316 KB Output is correct
37 Correct 12 ms 2396 KB Output is correct
38 Correct 12 ms 2140 KB Output is correct
39 Correct 12 ms 2140 KB Output is correct
40 Correct 12 ms 2396 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 472 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
48 Correct 3 ms 860 KB Output is correct
49 Correct 5 ms 1112 KB Output is correct
50 Correct 9 ms 1884 KB Output is correct
51 Correct 13 ms 2616 KB Output is correct
52 Correct 14 ms 2652 KB Output is correct
53 Correct 14 ms 2652 KB Output is correct
54 Correct 16 ms 2652 KB Output is correct
55 Correct 13 ms 2780 KB Output is correct
56 Correct 14 ms 2652 KB Output is correct
57 Correct 13 ms 2800 KB Output is correct
58 Correct 16 ms 2652 KB Output is correct
59 Correct 20 ms 2652 KB Output is correct
60 Correct 14 ms 2648 KB Output is correct
61 Correct 14 ms 2656 KB Output is correct
62 Correct 13 ms 2572 KB Output is correct
63 Correct 14 ms 2652 KB Output is correct
64 Correct 13 ms 2616 KB Output is correct
65 Correct 14 ms 2652 KB Output is correct
66 Correct 13 ms 2652 KB Output is correct
67 Correct 14 ms 2652 KB Output is correct
68 Correct 16 ms 2776 KB Output is correct
69 Correct 13 ms 2652 KB Output is correct
70 Correct 13 ms 2604 KB Output is correct
71 Correct 5 ms 860 KB Output is correct
72 Correct 4 ms 908 KB Output is correct
73 Correct 4 ms 856 KB Output is correct
74 Correct 4 ms 860 KB Output is correct
75 Correct 4 ms 860 KB Output is correct
76 Correct 14 ms 1372 KB Output is correct
77 Correct 14 ms 1372 KB Output is correct
78 Correct 16 ms 1372 KB Output is correct
79 Correct 13 ms 1372 KB Output is correct
80 Correct 13 ms 1376 KB Output is correct
81 Correct 44 ms 2140 KB Output is correct
82 Correct 44 ms 2248 KB Output is correct
83 Correct 44 ms 2136 KB Output is correct
84 Correct 44 ms 2392 KB Output is correct
85 Correct 44 ms 2276 KB Output is correct
86 Correct 143 ms 2396 KB Output is correct
87 Correct 146 ms 2244 KB Output is correct
88 Correct 143 ms 2448 KB Output is correct
89 Correct 141 ms 2392 KB Output is correct
90 Correct 143 ms 2396 KB Output is correct
91 Correct 3334 ms 3924 KB Output is correct
92 Correct 3324 ms 4136 KB Output is correct
93 Correct 3294 ms 4136 KB Output is correct
94 Correct 3309 ms 4136 KB Output is correct
95 Correct 3321 ms 4144 KB Output is correct
96 Execution timed out 7049 ms 4948 KB Time limit exceeded
97 Halted 0 ms 0 KB -