Submission #531231

# Submission time Handle Problem Language Result Execution time Memory
531231 2022-02-28T05:42:39 Z azberjibiou Diversity (CEOI21_diversity) C++17
64 / 100
38 ms 5380 KB
#include <bits/stdc++.h>
#define gibon ios::sync_with_stdio(false); cin.tie(0);
#define fir first
#define sec second
#define pdd pair<double, double>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pmax pair<__int128, __int128>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
int dx[4]={0, 1, 0, -1}, dy[4]={1, 0, -1 , 0};
const int mxN=300003;
const int mxM=1010;
const int mxK=105;
const int MOD=1000000007;
const ll INF=1e18;
const ll P1=1000000007;
const ll P2=1000000009;
int N, Q;
int cnt[mxN];
ll ans;
vector <ll> v;
int main()
{
    gibon
    cin >> N >> Q;
    for(int i=1;i<=N;i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }
    for(int i=0;i<mxN;i++)  if(cnt[i]!=0)
    {
        v.push_back(cnt[i]);
    }
    sort(v.begin(), v.end());
    ans=(ll)N*(N+1)/2*(v.size());
    ll cnt1=0, cnt2=0;
    for(int i=0;i+1<v.size();i++)
    {
        int ele=v[i];
        if(cnt1>cnt2)   swap(cnt1, cnt2);
        cnt1+=ele;
        ans-=cnt1*(cnt1+1)/2+(N-cnt1)*(N-cnt1+1)/2;
    }
    cout << ans;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i=0;i+1<v.size();i++)
      |                 ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 520 KB Output is correct
5 Correct 9 ms 716 KB Output is correct
6 Correct 15 ms 936 KB Output is correct
7 Correct 17 ms 824 KB Output is correct
8 Correct 14 ms 844 KB Output is correct
9 Correct 15 ms 948 KB Output is correct
10 Correct 17 ms 1100 KB Output is correct
11 Correct 15 ms 844 KB Output is correct
12 Correct 15 ms 944 KB Output is correct
13 Correct 16 ms 952 KB Output is correct
14 Correct 15 ms 948 KB Output is correct
15 Correct 15 ms 936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 520 KB Output is correct
5 Correct 9 ms 716 KB Output is correct
6 Correct 15 ms 936 KB Output is correct
7 Correct 17 ms 824 KB Output is correct
8 Correct 14 ms 844 KB Output is correct
9 Correct 15 ms 948 KB Output is correct
10 Correct 17 ms 1100 KB Output is correct
11 Correct 15 ms 844 KB Output is correct
12 Correct 15 ms 944 KB Output is correct
13 Correct 16 ms 952 KB Output is correct
14 Correct 15 ms 948 KB Output is correct
15 Correct 15 ms 936 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 6 ms 456 KB Output is correct
20 Correct 12 ms 844 KB Output is correct
21 Correct 24 ms 1076 KB Output is correct
22 Correct 18 ms 972 KB Output is correct
23 Correct 18 ms 1072 KB Output is correct
24 Correct 16 ms 972 KB Output is correct
25 Correct 16 ms 964 KB Output is correct
26 Correct 17 ms 1064 KB Output is correct
27 Correct 16 ms 1056 KB Output is correct
28 Correct 20 ms 964 KB Output is correct
29 Correct 16 ms 964 KB Output is correct
30 Correct 16 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 520 KB Output is correct
5 Correct 9 ms 716 KB Output is correct
6 Correct 15 ms 936 KB Output is correct
7 Correct 17 ms 824 KB Output is correct
8 Correct 14 ms 844 KB Output is correct
9 Correct 15 ms 948 KB Output is correct
10 Correct 17 ms 1100 KB Output is correct
11 Correct 15 ms 844 KB Output is correct
12 Correct 15 ms 944 KB Output is correct
13 Correct 16 ms 952 KB Output is correct
14 Correct 15 ms 948 KB Output is correct
15 Correct 15 ms 936 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 6 ms 456 KB Output is correct
20 Correct 12 ms 844 KB Output is correct
21 Correct 24 ms 1076 KB Output is correct
22 Correct 18 ms 972 KB Output is correct
23 Correct 18 ms 1072 KB Output is correct
24 Correct 16 ms 972 KB Output is correct
25 Correct 16 ms 964 KB Output is correct
26 Correct 17 ms 1064 KB Output is correct
27 Correct 16 ms 1056 KB Output is correct
28 Correct 20 ms 964 KB Output is correct
29 Correct 16 ms 964 KB Output is correct
30 Correct 16 ms 1072 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 3 ms 436 KB Output is correct
38 Correct 4 ms 512 KB Output is correct
39 Correct 7 ms 716 KB Output is correct
40 Correct 13 ms 1084 KB Output is correct
41 Correct 18 ms 1464 KB Output is correct
42 Correct 21 ms 1452 KB Output is correct
43 Correct 18 ms 1348 KB Output is correct
44 Correct 18 ms 1452 KB Output is correct
45 Correct 21 ms 1448 KB Output is correct
46 Correct 18 ms 1348 KB Output is correct
47 Correct 18 ms 1356 KB Output is correct
48 Correct 18 ms 1348 KB Output is correct
49 Correct 18 ms 1484 KB Output is correct
50 Correct 18 ms 1452 KB Output is correct
51 Correct 18 ms 1452 KB Output is correct
52 Correct 18 ms 1460 KB Output is correct
53 Correct 18 ms 1452 KB Output is correct
54 Correct 18 ms 1476 KB Output is correct
55 Correct 18 ms 1452 KB Output is correct
56 Correct 18 ms 1452 KB Output is correct
57 Correct 18 ms 1464 KB Output is correct
58 Correct 18 ms 1460 KB Output is correct
59 Correct 18 ms 1484 KB Output is correct
60 Correct 18 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 6 ms 520 KB Output is correct
15 Correct 9 ms 716 KB Output is correct
16 Correct 15 ms 936 KB Output is correct
17 Correct 17 ms 824 KB Output is correct
18 Correct 14 ms 844 KB Output is correct
19 Correct 15 ms 948 KB Output is correct
20 Correct 17 ms 1100 KB Output is correct
21 Correct 15 ms 844 KB Output is correct
22 Correct 15 ms 944 KB Output is correct
23 Correct 16 ms 952 KB Output is correct
24 Correct 15 ms 948 KB Output is correct
25 Correct 15 ms 936 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 6 ms 456 KB Output is correct
30 Correct 12 ms 844 KB Output is correct
31 Correct 24 ms 1076 KB Output is correct
32 Correct 18 ms 972 KB Output is correct
33 Correct 18 ms 1072 KB Output is correct
34 Correct 16 ms 972 KB Output is correct
35 Correct 16 ms 964 KB Output is correct
36 Correct 17 ms 1064 KB Output is correct
37 Correct 16 ms 1056 KB Output is correct
38 Correct 20 ms 964 KB Output is correct
39 Correct 16 ms 964 KB Output is correct
40 Correct 16 ms 1072 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 328 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 3 ms 436 KB Output is correct
48 Correct 4 ms 512 KB Output is correct
49 Correct 7 ms 716 KB Output is correct
50 Correct 13 ms 1084 KB Output is correct
51 Correct 18 ms 1464 KB Output is correct
52 Correct 21 ms 1452 KB Output is correct
53 Correct 18 ms 1348 KB Output is correct
54 Correct 18 ms 1452 KB Output is correct
55 Correct 21 ms 1448 KB Output is correct
56 Correct 18 ms 1348 KB Output is correct
57 Correct 18 ms 1356 KB Output is correct
58 Correct 18 ms 1348 KB Output is correct
59 Correct 18 ms 1484 KB Output is correct
60 Correct 18 ms 1452 KB Output is correct
61 Correct 18 ms 1452 KB Output is correct
62 Correct 18 ms 1460 KB Output is correct
63 Correct 18 ms 1452 KB Output is correct
64 Correct 18 ms 1476 KB Output is correct
65 Correct 18 ms 1452 KB Output is correct
66 Correct 18 ms 1452 KB Output is correct
67 Correct 18 ms 1464 KB Output is correct
68 Correct 18 ms 1460 KB Output is correct
69 Correct 18 ms 1484 KB Output is correct
70 Correct 18 ms 1484 KB Output is correct
71 Correct 4 ms 556 KB Output is correct
72 Correct 4 ms 544 KB Output is correct
73 Correct 4 ms 460 KB Output is correct
74 Correct 4 ms 568 KB Output is correct
75 Correct 4 ms 460 KB Output is correct
76 Correct 7 ms 844 KB Output is correct
77 Correct 7 ms 836 KB Output is correct
78 Correct 7 ms 832 KB Output is correct
79 Correct 8 ms 840 KB Output is correct
80 Correct 7 ms 832 KB Output is correct
81 Correct 14 ms 1476 KB Output is correct
82 Correct 14 ms 1496 KB Output is correct
83 Correct 14 ms 1424 KB Output is correct
84 Correct 15 ms 1488 KB Output is correct
85 Correct 14 ms 1476 KB Output is correct
86 Correct 16 ms 1772 KB Output is correct
87 Correct 16 ms 1736 KB Output is correct
88 Correct 16 ms 1832 KB Output is correct
89 Correct 16 ms 1736 KB Output is correct
90 Correct 16 ms 1772 KB Output is correct
91 Correct 26 ms 3504 KB Output is correct
92 Correct 27 ms 3524 KB Output is correct
93 Correct 25 ms 3508 KB Output is correct
94 Correct 26 ms 3504 KB Output is correct
95 Correct 26 ms 3496 KB Output is correct
96 Correct 35 ms 5172 KB Output is correct
97 Correct 32 ms 5156 KB Output is correct
98 Correct 31 ms 5060 KB Output is correct
99 Correct 30 ms 5056 KB Output is correct
100 Correct 31 ms 5164 KB Output is correct
101 Correct 32 ms 5168 KB Output is correct
102 Correct 34 ms 5148 KB Output is correct
103 Correct 31 ms 5160 KB Output is correct
104 Correct 30 ms 5056 KB Output is correct
105 Correct 34 ms 5180 KB Output is correct
106 Correct 32 ms 5380 KB Output is correct
107 Correct 34 ms 5308 KB Output is correct
108 Correct 31 ms 5376 KB Output is correct
109 Correct 30 ms 5336 KB Output is correct
110 Correct 38 ms 5364 KB Output is correct
111 Correct 31 ms 5360 KB Output is correct
112 Correct 31 ms 5316 KB Output is correct
113 Correct 32 ms 5360 KB Output is correct
114 Correct 31 ms 5308 KB Output is correct
115 Correct 31 ms 5316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 6 ms 520 KB Output is correct
15 Correct 9 ms 716 KB Output is correct
16 Correct 15 ms 936 KB Output is correct
17 Correct 17 ms 824 KB Output is correct
18 Correct 14 ms 844 KB Output is correct
19 Correct 15 ms 948 KB Output is correct
20 Correct 17 ms 1100 KB Output is correct
21 Correct 15 ms 844 KB Output is correct
22 Correct 15 ms 944 KB Output is correct
23 Correct 16 ms 952 KB Output is correct
24 Correct 15 ms 948 KB Output is correct
25 Correct 15 ms 936 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 6 ms 456 KB Output is correct
30 Correct 12 ms 844 KB Output is correct
31 Correct 24 ms 1076 KB Output is correct
32 Correct 18 ms 972 KB Output is correct
33 Correct 18 ms 1072 KB Output is correct
34 Correct 16 ms 972 KB Output is correct
35 Correct 16 ms 964 KB Output is correct
36 Correct 17 ms 1064 KB Output is correct
37 Correct 16 ms 1056 KB Output is correct
38 Correct 20 ms 964 KB Output is correct
39 Correct 16 ms 964 KB Output is correct
40 Correct 16 ms 1072 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 328 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 3 ms 436 KB Output is correct
48 Correct 4 ms 512 KB Output is correct
49 Correct 7 ms 716 KB Output is correct
50 Correct 13 ms 1084 KB Output is correct
51 Correct 18 ms 1464 KB Output is correct
52 Correct 21 ms 1452 KB Output is correct
53 Correct 18 ms 1348 KB Output is correct
54 Correct 18 ms 1452 KB Output is correct
55 Correct 21 ms 1448 KB Output is correct
56 Correct 18 ms 1348 KB Output is correct
57 Correct 18 ms 1356 KB Output is correct
58 Correct 18 ms 1348 KB Output is correct
59 Correct 18 ms 1484 KB Output is correct
60 Correct 18 ms 1452 KB Output is correct
61 Correct 18 ms 1452 KB Output is correct
62 Correct 18 ms 1460 KB Output is correct
63 Correct 18 ms 1452 KB Output is correct
64 Correct 18 ms 1476 KB Output is correct
65 Correct 18 ms 1452 KB Output is correct
66 Correct 18 ms 1452 KB Output is correct
67 Correct 18 ms 1464 KB Output is correct
68 Correct 18 ms 1460 KB Output is correct
69 Correct 18 ms 1484 KB Output is correct
70 Correct 18 ms 1484 KB Output is correct
71 Correct 4 ms 556 KB Output is correct
72 Correct 4 ms 544 KB Output is correct
73 Correct 4 ms 460 KB Output is correct
74 Correct 4 ms 568 KB Output is correct
75 Correct 4 ms 460 KB Output is correct
76 Correct 7 ms 844 KB Output is correct
77 Correct 7 ms 836 KB Output is correct
78 Correct 7 ms 832 KB Output is correct
79 Correct 8 ms 840 KB Output is correct
80 Correct 7 ms 832 KB Output is correct
81 Correct 14 ms 1476 KB Output is correct
82 Correct 14 ms 1496 KB Output is correct
83 Correct 14 ms 1424 KB Output is correct
84 Correct 15 ms 1488 KB Output is correct
85 Correct 14 ms 1476 KB Output is correct
86 Correct 16 ms 1772 KB Output is correct
87 Correct 16 ms 1736 KB Output is correct
88 Correct 16 ms 1832 KB Output is correct
89 Correct 16 ms 1736 KB Output is correct
90 Correct 16 ms 1772 KB Output is correct
91 Correct 26 ms 3504 KB Output is correct
92 Correct 27 ms 3524 KB Output is correct
93 Correct 25 ms 3508 KB Output is correct
94 Correct 26 ms 3504 KB Output is correct
95 Correct 26 ms 3496 KB Output is correct
96 Correct 35 ms 5172 KB Output is correct
97 Correct 32 ms 5156 KB Output is correct
98 Correct 31 ms 5060 KB Output is correct
99 Correct 30 ms 5056 KB Output is correct
100 Correct 31 ms 5164 KB Output is correct
101 Correct 32 ms 5168 KB Output is correct
102 Correct 34 ms 5148 KB Output is correct
103 Correct 31 ms 5160 KB Output is correct
104 Correct 30 ms 5056 KB Output is correct
105 Correct 34 ms 5180 KB Output is correct
106 Correct 32 ms 5380 KB Output is correct
107 Correct 34 ms 5308 KB Output is correct
108 Correct 31 ms 5376 KB Output is correct
109 Correct 30 ms 5336 KB Output is correct
110 Correct 38 ms 5364 KB Output is correct
111 Correct 31 ms 5360 KB Output is correct
112 Correct 31 ms 5316 KB Output is correct
113 Correct 32 ms 5360 KB Output is correct
114 Correct 31 ms 5308 KB Output is correct
115 Correct 31 ms 5316 KB Output is correct
116 Incorrect 1 ms 332 KB Output isn't correct
117 Halted 0 ms 0 KB -