Submission #528187

# Submission time Handle Problem Language Result Execution time Memory
528187 2022-02-19T16:17:01 Z Rafi22 Diversity (CEOI21_diversity) C++14
64 / 100
40 ms 6884 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;
#define int long long

ll cnt[300007];
ll x[300007];

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* vector<int>P(10),p(10),best;
    for(int i=0;i<10;i++)
    {
        P[i]=(i+1)*(i+1)*(i+1)*(i+1);
        p[i]=i;
    }
    sort(all(P));
    int ans=inf;
    while(true)
    {
        int act=0;
        for(int i=0;i<10;i++)
        {
            for(int j=i+1;j<10;j++)
            {
                act+=P[p[i]]*P[p[j]]*(j-i+1);
            }
        }
        if(act<ans)
        {
            cout<<act<<endl;
            ans=act;
            best=p;
        }
        else if(act==ans) cout<<"XD"<<endl;
        if(!next_permutation(all(p))) break;
    }
    for(int i=0;i<10;i++) cout<<best[i]<<" ";
    cout<<endl;
    cout<<ans<<endl;
    for(int i=0;i<10;i++) cout<<P[best[i]]<<" ";*/
    int n,a,q;
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        cnt[a]++;
    }
    int mx=300000;
    sort(cnt+1,cnt+mx+1);
    int it=0,it1=mx+1;
    for(int i=1;i<=mx;i++)
    {
        if(i%2) x[++it]=cnt[i];
        else x[--it1]=cnt[i];
    }
    ll ans=0;
    ll sum=0,sum1=0;
    for(int i=1;i<=mx;i++)
    {
        ans+=x[i]*(x[i]+1)/2;
        ans+=x[i]*(i+1)*sum;
        ans+=x[i]*sum1;
        sum+=x[i];
        sum1-=i*x[i];
    }
    cout<<ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4940 KB Output is correct
2 Correct 7 ms 4940 KB Output is correct
3 Correct 7 ms 4940 KB Output is correct
4 Correct 8 ms 4940 KB Output is correct
5 Correct 6 ms 4964 KB Output is correct
6 Correct 7 ms 4940 KB Output is correct
7 Correct 9 ms 4940 KB Output is correct
8 Correct 7 ms 4964 KB Output is correct
9 Correct 7 ms 4940 KB Output is correct
10 Correct 6 ms 4964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 5012 KB Output is correct
2 Correct 6 ms 4968 KB Output is correct
3 Correct 7 ms 4964 KB Output is correct
4 Correct 10 ms 4940 KB Output is correct
5 Correct 16 ms 4968 KB Output is correct
6 Correct 20 ms 4940 KB Output is correct
7 Correct 19 ms 4932 KB Output is correct
8 Correct 19 ms 4936 KB Output is correct
9 Correct 26 ms 5064 KB Output is correct
10 Correct 20 ms 4976 KB Output is correct
11 Correct 20 ms 4936 KB Output is correct
12 Correct 20 ms 4932 KB Output is correct
13 Correct 20 ms 4924 KB Output is correct
14 Correct 19 ms 4936 KB Output is correct
15 Correct 19 ms 4932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 5012 KB Output is correct
2 Correct 6 ms 4968 KB Output is correct
3 Correct 7 ms 4964 KB Output is correct
4 Correct 10 ms 4940 KB Output is correct
5 Correct 16 ms 4968 KB Output is correct
6 Correct 20 ms 4940 KB Output is correct
7 Correct 19 ms 4932 KB Output is correct
8 Correct 19 ms 4936 KB Output is correct
9 Correct 26 ms 5064 KB Output is correct
10 Correct 20 ms 4976 KB Output is correct
11 Correct 20 ms 4936 KB Output is correct
12 Correct 20 ms 4932 KB Output is correct
13 Correct 20 ms 4924 KB Output is correct
14 Correct 19 ms 4936 KB Output is correct
15 Correct 19 ms 4932 KB Output is correct
16 Correct 6 ms 4940 KB Output is correct
17 Correct 6 ms 4976 KB Output is correct
18 Correct 7 ms 4932 KB Output is correct
19 Correct 11 ms 4976 KB Output is correct
20 Correct 16 ms 4932 KB Output is correct
21 Correct 21 ms 4932 KB Output is correct
22 Correct 21 ms 4932 KB Output is correct
23 Correct 21 ms 4968 KB Output is correct
24 Correct 27 ms 4936 KB Output is correct
25 Correct 33 ms 4932 KB Output is correct
26 Correct 21 ms 4936 KB Output is correct
27 Correct 21 ms 4928 KB Output is correct
28 Correct 21 ms 4932 KB Output is correct
29 Correct 21 ms 4936 KB Output is correct
30 Correct 21 ms 4936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 5012 KB Output is correct
2 Correct 6 ms 4968 KB Output is correct
3 Correct 7 ms 4964 KB Output is correct
4 Correct 10 ms 4940 KB Output is correct
5 Correct 16 ms 4968 KB Output is correct
6 Correct 20 ms 4940 KB Output is correct
7 Correct 19 ms 4932 KB Output is correct
8 Correct 19 ms 4936 KB Output is correct
9 Correct 26 ms 5064 KB Output is correct
10 Correct 20 ms 4976 KB Output is correct
11 Correct 20 ms 4936 KB Output is correct
12 Correct 20 ms 4932 KB Output is correct
13 Correct 20 ms 4924 KB Output is correct
14 Correct 19 ms 4936 KB Output is correct
15 Correct 19 ms 4932 KB Output is correct
16 Correct 6 ms 4940 KB Output is correct
17 Correct 6 ms 4976 KB Output is correct
18 Correct 7 ms 4932 KB Output is correct
19 Correct 11 ms 4976 KB Output is correct
20 Correct 16 ms 4932 KB Output is correct
21 Correct 21 ms 4932 KB Output is correct
22 Correct 21 ms 4932 KB Output is correct
23 Correct 21 ms 4968 KB Output is correct
24 Correct 27 ms 4936 KB Output is correct
25 Correct 33 ms 4932 KB Output is correct
26 Correct 21 ms 4936 KB Output is correct
27 Correct 21 ms 4928 KB Output is correct
28 Correct 21 ms 4932 KB Output is correct
29 Correct 21 ms 4936 KB Output is correct
30 Correct 21 ms 4936 KB Output is correct
31 Correct 7 ms 4940 KB Output is correct
32 Correct 6 ms 4972 KB Output is correct
33 Correct 7 ms 4940 KB Output is correct
34 Correct 8 ms 4940 KB Output is correct
35 Correct 8 ms 4940 KB Output is correct
36 Correct 8 ms 4940 KB Output is correct
37 Correct 13 ms 4968 KB Output is correct
38 Correct 9 ms 4940 KB Output is correct
39 Correct 14 ms 5068 KB Output is correct
40 Correct 17 ms 4972 KB Output is correct
41 Correct 22 ms 4940 KB Output is correct
42 Correct 23 ms 4972 KB Output is correct
43 Correct 22 ms 4944 KB Output is correct
44 Correct 22 ms 4992 KB Output is correct
45 Correct 22 ms 4948 KB Output is correct
46 Correct 28 ms 4940 KB Output is correct
47 Correct 34 ms 4932 KB Output is correct
48 Correct 23 ms 4940 KB Output is correct
49 Correct 22 ms 4936 KB Output is correct
50 Correct 22 ms 4936 KB Output is correct
51 Correct 26 ms 4972 KB Output is correct
52 Correct 23 ms 4940 KB Output is correct
53 Correct 23 ms 4940 KB Output is correct
54 Correct 22 ms 4956 KB Output is correct
55 Correct 23 ms 4944 KB Output is correct
56 Correct 25 ms 4976 KB Output is correct
57 Correct 26 ms 4936 KB Output is correct
58 Correct 25 ms 4976 KB Output is correct
59 Correct 23 ms 4944 KB Output is correct
60 Correct 23 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4940 KB Output is correct
2 Correct 7 ms 4940 KB Output is correct
3 Correct 7 ms 4940 KB Output is correct
4 Correct 8 ms 4940 KB Output is correct
5 Correct 6 ms 4964 KB Output is correct
6 Correct 7 ms 4940 KB Output is correct
7 Correct 9 ms 4940 KB Output is correct
8 Correct 7 ms 4964 KB Output is correct
9 Correct 7 ms 4940 KB Output is correct
10 Correct 6 ms 4964 KB Output is correct
11 Correct 9 ms 5012 KB Output is correct
12 Correct 6 ms 4968 KB Output is correct
13 Correct 7 ms 4964 KB Output is correct
14 Correct 10 ms 4940 KB Output is correct
15 Correct 16 ms 4968 KB Output is correct
16 Correct 20 ms 4940 KB Output is correct
17 Correct 19 ms 4932 KB Output is correct
18 Correct 19 ms 4936 KB Output is correct
19 Correct 26 ms 5064 KB Output is correct
20 Correct 20 ms 4976 KB Output is correct
21 Correct 20 ms 4936 KB Output is correct
22 Correct 20 ms 4932 KB Output is correct
23 Correct 20 ms 4924 KB Output is correct
24 Correct 19 ms 4936 KB Output is correct
25 Correct 19 ms 4932 KB Output is correct
26 Correct 6 ms 4940 KB Output is correct
27 Correct 6 ms 4976 KB Output is correct
28 Correct 7 ms 4932 KB Output is correct
29 Correct 11 ms 4976 KB Output is correct
30 Correct 16 ms 4932 KB Output is correct
31 Correct 21 ms 4932 KB Output is correct
32 Correct 21 ms 4932 KB Output is correct
33 Correct 21 ms 4968 KB Output is correct
34 Correct 27 ms 4936 KB Output is correct
35 Correct 33 ms 4932 KB Output is correct
36 Correct 21 ms 4936 KB Output is correct
37 Correct 21 ms 4928 KB Output is correct
38 Correct 21 ms 4932 KB Output is correct
39 Correct 21 ms 4936 KB Output is correct
40 Correct 21 ms 4936 KB Output is correct
41 Correct 7 ms 4940 KB Output is correct
42 Correct 6 ms 4972 KB Output is correct
43 Correct 7 ms 4940 KB Output is correct
44 Correct 8 ms 4940 KB Output is correct
45 Correct 8 ms 4940 KB Output is correct
46 Correct 8 ms 4940 KB Output is correct
47 Correct 13 ms 4968 KB Output is correct
48 Correct 9 ms 4940 KB Output is correct
49 Correct 14 ms 5068 KB Output is correct
50 Correct 17 ms 4972 KB Output is correct
51 Correct 22 ms 4940 KB Output is correct
52 Correct 23 ms 4972 KB Output is correct
53 Correct 22 ms 4944 KB Output is correct
54 Correct 22 ms 4992 KB Output is correct
55 Correct 22 ms 4948 KB Output is correct
56 Correct 28 ms 4940 KB Output is correct
57 Correct 34 ms 4932 KB Output is correct
58 Correct 23 ms 4940 KB Output is correct
59 Correct 22 ms 4936 KB Output is correct
60 Correct 22 ms 4936 KB Output is correct
61 Correct 26 ms 4972 KB Output is correct
62 Correct 23 ms 4940 KB Output is correct
63 Correct 23 ms 4940 KB Output is correct
64 Correct 22 ms 4956 KB Output is correct
65 Correct 23 ms 4944 KB Output is correct
66 Correct 25 ms 4976 KB Output is correct
67 Correct 26 ms 4936 KB Output is correct
68 Correct 25 ms 4976 KB Output is correct
69 Correct 23 ms 4944 KB Output is correct
70 Correct 23 ms 4940 KB Output is correct
71 Correct 10 ms 4940 KB Output is correct
72 Correct 10 ms 5192 KB Output is correct
73 Correct 10 ms 5176 KB Output is correct
74 Correct 14 ms 5196 KB Output is correct
75 Correct 14 ms 5188 KB Output is correct
76 Correct 13 ms 5452 KB Output is correct
77 Correct 13 ms 5344 KB Output is correct
78 Correct 13 ms 5476 KB Output is correct
79 Correct 13 ms 5472 KB Output is correct
80 Correct 13 ms 5460 KB Output is correct
81 Correct 20 ms 5892 KB Output is correct
82 Correct 22 ms 5876 KB Output is correct
83 Correct 20 ms 5872 KB Output is correct
84 Correct 20 ms 5876 KB Output is correct
85 Correct 19 ms 5952 KB Output is correct
86 Correct 21 ms 5968 KB Output is correct
87 Correct 23 ms 5956 KB Output is correct
88 Correct 22 ms 6016 KB Output is correct
89 Correct 21 ms 5972 KB Output is correct
90 Correct 20 ms 5956 KB Output is correct
91 Correct 29 ms 6724 KB Output is correct
92 Correct 34 ms 6708 KB Output is correct
93 Correct 29 ms 6720 KB Output is correct
94 Correct 29 ms 6720 KB Output is correct
95 Correct 29 ms 6724 KB Output is correct
96 Correct 33 ms 6848 KB Output is correct
97 Correct 32 ms 6856 KB Output is correct
98 Correct 31 ms 6848 KB Output is correct
99 Correct 36 ms 6852 KB Output is correct
100 Correct 34 ms 6856 KB Output is correct
101 Correct 33 ms 6840 KB Output is correct
102 Correct 40 ms 6860 KB Output is correct
103 Correct 32 ms 6848 KB Output is correct
104 Correct 34 ms 6848 KB Output is correct
105 Correct 36 ms 6848 KB Output is correct
106 Correct 34 ms 6852 KB Output is correct
107 Correct 34 ms 6864 KB Output is correct
108 Correct 32 ms 6868 KB Output is correct
109 Correct 33 ms 6856 KB Output is correct
110 Correct 33 ms 6856 KB Output is correct
111 Correct 34 ms 6856 KB Output is correct
112 Correct 31 ms 6868 KB Output is correct
113 Correct 32 ms 6864 KB Output is correct
114 Correct 31 ms 6872 KB Output is correct
115 Correct 35 ms 6884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4940 KB Output is correct
2 Correct 7 ms 4940 KB Output is correct
3 Correct 7 ms 4940 KB Output is correct
4 Correct 8 ms 4940 KB Output is correct
5 Correct 6 ms 4964 KB Output is correct
6 Correct 7 ms 4940 KB Output is correct
7 Correct 9 ms 4940 KB Output is correct
8 Correct 7 ms 4964 KB Output is correct
9 Correct 7 ms 4940 KB Output is correct
10 Correct 6 ms 4964 KB Output is correct
11 Correct 9 ms 5012 KB Output is correct
12 Correct 6 ms 4968 KB Output is correct
13 Correct 7 ms 4964 KB Output is correct
14 Correct 10 ms 4940 KB Output is correct
15 Correct 16 ms 4968 KB Output is correct
16 Correct 20 ms 4940 KB Output is correct
17 Correct 19 ms 4932 KB Output is correct
18 Correct 19 ms 4936 KB Output is correct
19 Correct 26 ms 5064 KB Output is correct
20 Correct 20 ms 4976 KB Output is correct
21 Correct 20 ms 4936 KB Output is correct
22 Correct 20 ms 4932 KB Output is correct
23 Correct 20 ms 4924 KB Output is correct
24 Correct 19 ms 4936 KB Output is correct
25 Correct 19 ms 4932 KB Output is correct
26 Correct 6 ms 4940 KB Output is correct
27 Correct 6 ms 4976 KB Output is correct
28 Correct 7 ms 4932 KB Output is correct
29 Correct 11 ms 4976 KB Output is correct
30 Correct 16 ms 4932 KB Output is correct
31 Correct 21 ms 4932 KB Output is correct
32 Correct 21 ms 4932 KB Output is correct
33 Correct 21 ms 4968 KB Output is correct
34 Correct 27 ms 4936 KB Output is correct
35 Correct 33 ms 4932 KB Output is correct
36 Correct 21 ms 4936 KB Output is correct
37 Correct 21 ms 4928 KB Output is correct
38 Correct 21 ms 4932 KB Output is correct
39 Correct 21 ms 4936 KB Output is correct
40 Correct 21 ms 4936 KB Output is correct
41 Correct 7 ms 4940 KB Output is correct
42 Correct 6 ms 4972 KB Output is correct
43 Correct 7 ms 4940 KB Output is correct
44 Correct 8 ms 4940 KB Output is correct
45 Correct 8 ms 4940 KB Output is correct
46 Correct 8 ms 4940 KB Output is correct
47 Correct 13 ms 4968 KB Output is correct
48 Correct 9 ms 4940 KB Output is correct
49 Correct 14 ms 5068 KB Output is correct
50 Correct 17 ms 4972 KB Output is correct
51 Correct 22 ms 4940 KB Output is correct
52 Correct 23 ms 4972 KB Output is correct
53 Correct 22 ms 4944 KB Output is correct
54 Correct 22 ms 4992 KB Output is correct
55 Correct 22 ms 4948 KB Output is correct
56 Correct 28 ms 4940 KB Output is correct
57 Correct 34 ms 4932 KB Output is correct
58 Correct 23 ms 4940 KB Output is correct
59 Correct 22 ms 4936 KB Output is correct
60 Correct 22 ms 4936 KB Output is correct
61 Correct 26 ms 4972 KB Output is correct
62 Correct 23 ms 4940 KB Output is correct
63 Correct 23 ms 4940 KB Output is correct
64 Correct 22 ms 4956 KB Output is correct
65 Correct 23 ms 4944 KB Output is correct
66 Correct 25 ms 4976 KB Output is correct
67 Correct 26 ms 4936 KB Output is correct
68 Correct 25 ms 4976 KB Output is correct
69 Correct 23 ms 4944 KB Output is correct
70 Correct 23 ms 4940 KB Output is correct
71 Correct 10 ms 4940 KB Output is correct
72 Correct 10 ms 5192 KB Output is correct
73 Correct 10 ms 5176 KB Output is correct
74 Correct 14 ms 5196 KB Output is correct
75 Correct 14 ms 5188 KB Output is correct
76 Correct 13 ms 5452 KB Output is correct
77 Correct 13 ms 5344 KB Output is correct
78 Correct 13 ms 5476 KB Output is correct
79 Correct 13 ms 5472 KB Output is correct
80 Correct 13 ms 5460 KB Output is correct
81 Correct 20 ms 5892 KB Output is correct
82 Correct 22 ms 5876 KB Output is correct
83 Correct 20 ms 5872 KB Output is correct
84 Correct 20 ms 5876 KB Output is correct
85 Correct 19 ms 5952 KB Output is correct
86 Correct 21 ms 5968 KB Output is correct
87 Correct 23 ms 5956 KB Output is correct
88 Correct 22 ms 6016 KB Output is correct
89 Correct 21 ms 5972 KB Output is correct
90 Correct 20 ms 5956 KB Output is correct
91 Correct 29 ms 6724 KB Output is correct
92 Correct 34 ms 6708 KB Output is correct
93 Correct 29 ms 6720 KB Output is correct
94 Correct 29 ms 6720 KB Output is correct
95 Correct 29 ms 6724 KB Output is correct
96 Correct 33 ms 6848 KB Output is correct
97 Correct 32 ms 6856 KB Output is correct
98 Correct 31 ms 6848 KB Output is correct
99 Correct 36 ms 6852 KB Output is correct
100 Correct 34 ms 6856 KB Output is correct
101 Correct 33 ms 6840 KB Output is correct
102 Correct 40 ms 6860 KB Output is correct
103 Correct 32 ms 6848 KB Output is correct
104 Correct 34 ms 6848 KB Output is correct
105 Correct 36 ms 6848 KB Output is correct
106 Correct 34 ms 6852 KB Output is correct
107 Correct 34 ms 6864 KB Output is correct
108 Correct 32 ms 6868 KB Output is correct
109 Correct 33 ms 6856 KB Output is correct
110 Correct 33 ms 6856 KB Output is correct
111 Correct 34 ms 6856 KB Output is correct
112 Correct 31 ms 6868 KB Output is correct
113 Correct 32 ms 6864 KB Output is correct
114 Correct 31 ms 6872 KB Output is correct
115 Correct 35 ms 6884 KB Output is correct
116 Incorrect 7 ms 5068 KB Output isn't correct
117 Halted 0 ms 0 KB -