Submission #708165

# Submission time Handle Problem Language Result Execution time Memory
708165 2023-03-11T07:45:02 Z vjudge1 Diversity (CEOI21_diversity) C++11
64 / 100
330 ms 15260 KB
// CEOI 2021 Day1 Diversity
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> A(n);
  map<int, int> M;
  for (int &a : A) cin >> a, M[a] = 0;
  int k = 0;
  for (auto &p : M) p.second = k++;
  vector<LL> cnt(k);
  for (int &a : A) a = M[a], ++cnt[a];  // 离散化

  int L, R;
  cin >> L >> R;
  if (q > 1) return 0;  // 只考虑64分的情况
  assert(q == 1 && L == 1 && R == n);

  LL ans = 0, BC[2] = {0}, bi = 0;
  sort(cnt.begin(), cnt.end());
  for (LL c : cnt) {  // 实验确定: 最优解一定是 元素的出现次数先递增再递减
    ans += c * (c + 1) / 2 + c * (n - c);
    LL &b = BC[bi ^= 1];
    ans += b * (n - c - b), b += c;
  }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 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 340 KB Output is correct
4 Correct 8 ms 596 KB Output is correct
5 Correct 16 ms 1108 KB Output is correct
6 Correct 25 ms 1492 KB Output is correct
7 Correct 28 ms 1492 KB Output is correct
8 Correct 31 ms 1492 KB Output is correct
9 Correct 27 ms 1492 KB Output is correct
10 Correct 21 ms 1492 KB Output is correct
11 Correct 26 ms 1492 KB Output is correct
12 Correct 24 ms 1492 KB Output is correct
13 Correct 23 ms 1492 KB Output is correct
14 Correct 23 ms 1492 KB Output is correct
15 Correct 24 ms 1492 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 340 KB Output is correct
4 Correct 8 ms 596 KB Output is correct
5 Correct 16 ms 1108 KB Output is correct
6 Correct 25 ms 1492 KB Output is correct
7 Correct 28 ms 1492 KB Output is correct
8 Correct 31 ms 1492 KB Output is correct
9 Correct 27 ms 1492 KB Output is correct
10 Correct 21 ms 1492 KB Output is correct
11 Correct 26 ms 1492 KB Output is correct
12 Correct 24 ms 1492 KB Output is correct
13 Correct 23 ms 1492 KB Output is correct
14 Correct 23 ms 1492 KB Output is correct
15 Correct 24 ms 1492 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 11 ms 596 KB Output is correct
20 Correct 19 ms 1108 KB Output is correct
21 Correct 30 ms 1492 KB Output is correct
22 Correct 29 ms 1492 KB Output is correct
23 Correct 36 ms 1492 KB Output is correct
24 Correct 28 ms 1492 KB Output is correct
25 Correct 32 ms 1492 KB Output is correct
26 Correct 31 ms 1492 KB Output is correct
27 Correct 36 ms 1492 KB Output is correct
28 Correct 30 ms 1492 KB Output is correct
29 Correct 28 ms 1492 KB Output is correct
30 Correct 29 ms 1492 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 340 KB Output is correct
4 Correct 8 ms 596 KB Output is correct
5 Correct 16 ms 1108 KB Output is correct
6 Correct 25 ms 1492 KB Output is correct
7 Correct 28 ms 1492 KB Output is correct
8 Correct 31 ms 1492 KB Output is correct
9 Correct 27 ms 1492 KB Output is correct
10 Correct 21 ms 1492 KB Output is correct
11 Correct 26 ms 1492 KB Output is correct
12 Correct 24 ms 1492 KB Output is correct
13 Correct 23 ms 1492 KB Output is correct
14 Correct 23 ms 1492 KB Output is correct
15 Correct 24 ms 1492 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 11 ms 596 KB Output is correct
20 Correct 19 ms 1108 KB Output is correct
21 Correct 30 ms 1492 KB Output is correct
22 Correct 29 ms 1492 KB Output is correct
23 Correct 36 ms 1492 KB Output is correct
24 Correct 28 ms 1492 KB Output is correct
25 Correct 32 ms 1492 KB Output is correct
26 Correct 31 ms 1492 KB Output is correct
27 Correct 36 ms 1492 KB Output is correct
28 Correct 30 ms 1492 KB Output is correct
29 Correct 28 ms 1492 KB Output is correct
30 Correct 29 ms 1492 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 9 ms 468 KB Output is correct
38 Correct 12 ms 468 KB Output is correct
39 Correct 18 ms 768 KB Output is correct
40 Correct 37 ms 1164 KB Output is correct
41 Correct 52 ms 1556 KB Output is correct
42 Correct 61 ms 1492 KB Output is correct
43 Correct 57 ms 1552 KB Output is correct
44 Correct 55 ms 1492 KB Output is correct
45 Correct 52 ms 1492 KB Output is correct
46 Correct 63 ms 1492 KB Output is correct
47 Correct 52 ms 1548 KB Output is correct
48 Correct 53 ms 1552 KB Output is correct
49 Correct 53 ms 1528 KB Output is correct
50 Correct 55 ms 1492 KB Output is correct
51 Correct 55 ms 1528 KB Output is correct
52 Correct 54 ms 1492 KB Output is correct
53 Correct 57 ms 1552 KB Output is correct
54 Correct 53 ms 1492 KB Output is correct
55 Correct 52 ms 1492 KB Output is correct
56 Correct 52 ms 1544 KB Output is correct
57 Correct 53 ms 1548 KB Output is correct
58 Correct 53 ms 1612 KB Output is correct
59 Correct 52 ms 1492 KB Output is correct
60 Correct 56 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 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 340 KB Output is correct
14 Correct 8 ms 596 KB Output is correct
15 Correct 16 ms 1108 KB Output is correct
16 Correct 25 ms 1492 KB Output is correct
17 Correct 28 ms 1492 KB Output is correct
18 Correct 31 ms 1492 KB Output is correct
19 Correct 27 ms 1492 KB Output is correct
20 Correct 21 ms 1492 KB Output is correct
21 Correct 26 ms 1492 KB Output is correct
22 Correct 24 ms 1492 KB Output is correct
23 Correct 23 ms 1492 KB Output is correct
24 Correct 23 ms 1492 KB Output is correct
25 Correct 24 ms 1492 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 11 ms 596 KB Output is correct
30 Correct 19 ms 1108 KB Output is correct
31 Correct 30 ms 1492 KB Output is correct
32 Correct 29 ms 1492 KB Output is correct
33 Correct 36 ms 1492 KB Output is correct
34 Correct 28 ms 1492 KB Output is correct
35 Correct 32 ms 1492 KB Output is correct
36 Correct 31 ms 1492 KB Output is correct
37 Correct 36 ms 1492 KB Output is correct
38 Correct 30 ms 1492 KB Output is correct
39 Correct 28 ms 1492 KB Output is correct
40 Correct 29 ms 1492 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 9 ms 468 KB Output is correct
48 Correct 12 ms 468 KB Output is correct
49 Correct 18 ms 768 KB Output is correct
50 Correct 37 ms 1164 KB Output is correct
51 Correct 52 ms 1556 KB Output is correct
52 Correct 61 ms 1492 KB Output is correct
53 Correct 57 ms 1552 KB Output is correct
54 Correct 55 ms 1492 KB Output is correct
55 Correct 52 ms 1492 KB Output is correct
56 Correct 63 ms 1492 KB Output is correct
57 Correct 52 ms 1548 KB Output is correct
58 Correct 53 ms 1552 KB Output is correct
59 Correct 53 ms 1528 KB Output is correct
60 Correct 55 ms 1492 KB Output is correct
61 Correct 55 ms 1528 KB Output is correct
62 Correct 54 ms 1492 KB Output is correct
63 Correct 57 ms 1552 KB Output is correct
64 Correct 53 ms 1492 KB Output is correct
65 Correct 52 ms 1492 KB Output is correct
66 Correct 52 ms 1544 KB Output is correct
67 Correct 53 ms 1548 KB Output is correct
68 Correct 53 ms 1612 KB Output is correct
69 Correct 52 ms 1492 KB Output is correct
70 Correct 56 ms 1492 KB Output is correct
71 Correct 14 ms 596 KB Output is correct
72 Correct 11 ms 596 KB Output is correct
73 Correct 13 ms 624 KB Output is correct
74 Correct 11 ms 748 KB Output is correct
75 Correct 11 ms 624 KB Output is correct
76 Correct 26 ms 980 KB Output is correct
77 Correct 30 ms 956 KB Output is correct
78 Correct 29 ms 1072 KB Output is correct
79 Correct 33 ms 1000 KB Output is correct
80 Correct 28 ms 924 KB Output is correct
81 Correct 65 ms 1612 KB Output is correct
82 Correct 55 ms 1572 KB Output is correct
83 Correct 58 ms 1580 KB Output is correct
84 Correct 57 ms 1716 KB Output is correct
85 Correct 56 ms 1732 KB Output is correct
86 Correct 81 ms 2140 KB Output is correct
87 Correct 66 ms 2124 KB Output is correct
88 Correct 68 ms 2152 KB Output is correct
89 Correct 82 ms 2188 KB Output is correct
90 Correct 70 ms 2140 KB Output is correct
91 Correct 172 ms 6968 KB Output is correct
92 Correct 147 ms 6936 KB Output is correct
93 Correct 175 ms 6972 KB Output is correct
94 Correct 205 ms 6980 KB Output is correct
95 Correct 159 ms 6860 KB Output is correct
96 Correct 266 ms 12324 KB Output is correct
97 Correct 287 ms 12364 KB Output is correct
98 Correct 275 ms 12420 KB Output is correct
99 Correct 308 ms 12364 KB Output is correct
100 Correct 284 ms 12492 KB Output is correct
101 Correct 235 ms 12448 KB Output is correct
102 Correct 243 ms 12448 KB Output is correct
103 Correct 255 ms 12408 KB Output is correct
104 Correct 248 ms 12444 KB Output is correct
105 Correct 274 ms 12540 KB Output is correct
106 Correct 288 ms 15192 KB Output is correct
107 Correct 305 ms 15100 KB Output is correct
108 Correct 295 ms 15156 KB Output is correct
109 Correct 316 ms 15128 KB Output is correct
110 Correct 330 ms 15092 KB Output is correct
111 Correct 288 ms 15260 KB Output is correct
112 Correct 291 ms 15188 KB Output is correct
113 Correct 289 ms 15216 KB Output is correct
114 Correct 297 ms 15160 KB Output is correct
115 Correct 322 ms 15216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 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 340 KB Output is correct
14 Correct 8 ms 596 KB Output is correct
15 Correct 16 ms 1108 KB Output is correct
16 Correct 25 ms 1492 KB Output is correct
17 Correct 28 ms 1492 KB Output is correct
18 Correct 31 ms 1492 KB Output is correct
19 Correct 27 ms 1492 KB Output is correct
20 Correct 21 ms 1492 KB Output is correct
21 Correct 26 ms 1492 KB Output is correct
22 Correct 24 ms 1492 KB Output is correct
23 Correct 23 ms 1492 KB Output is correct
24 Correct 23 ms 1492 KB Output is correct
25 Correct 24 ms 1492 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 11 ms 596 KB Output is correct
30 Correct 19 ms 1108 KB Output is correct
31 Correct 30 ms 1492 KB Output is correct
32 Correct 29 ms 1492 KB Output is correct
33 Correct 36 ms 1492 KB Output is correct
34 Correct 28 ms 1492 KB Output is correct
35 Correct 32 ms 1492 KB Output is correct
36 Correct 31 ms 1492 KB Output is correct
37 Correct 36 ms 1492 KB Output is correct
38 Correct 30 ms 1492 KB Output is correct
39 Correct 28 ms 1492 KB Output is correct
40 Correct 29 ms 1492 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 9 ms 468 KB Output is correct
48 Correct 12 ms 468 KB Output is correct
49 Correct 18 ms 768 KB Output is correct
50 Correct 37 ms 1164 KB Output is correct
51 Correct 52 ms 1556 KB Output is correct
52 Correct 61 ms 1492 KB Output is correct
53 Correct 57 ms 1552 KB Output is correct
54 Correct 55 ms 1492 KB Output is correct
55 Correct 52 ms 1492 KB Output is correct
56 Correct 63 ms 1492 KB Output is correct
57 Correct 52 ms 1548 KB Output is correct
58 Correct 53 ms 1552 KB Output is correct
59 Correct 53 ms 1528 KB Output is correct
60 Correct 55 ms 1492 KB Output is correct
61 Correct 55 ms 1528 KB Output is correct
62 Correct 54 ms 1492 KB Output is correct
63 Correct 57 ms 1552 KB Output is correct
64 Correct 53 ms 1492 KB Output is correct
65 Correct 52 ms 1492 KB Output is correct
66 Correct 52 ms 1544 KB Output is correct
67 Correct 53 ms 1548 KB Output is correct
68 Correct 53 ms 1612 KB Output is correct
69 Correct 52 ms 1492 KB Output is correct
70 Correct 56 ms 1492 KB Output is correct
71 Correct 14 ms 596 KB Output is correct
72 Correct 11 ms 596 KB Output is correct
73 Correct 13 ms 624 KB Output is correct
74 Correct 11 ms 748 KB Output is correct
75 Correct 11 ms 624 KB Output is correct
76 Correct 26 ms 980 KB Output is correct
77 Correct 30 ms 956 KB Output is correct
78 Correct 29 ms 1072 KB Output is correct
79 Correct 33 ms 1000 KB Output is correct
80 Correct 28 ms 924 KB Output is correct
81 Correct 65 ms 1612 KB Output is correct
82 Correct 55 ms 1572 KB Output is correct
83 Correct 58 ms 1580 KB Output is correct
84 Correct 57 ms 1716 KB Output is correct
85 Correct 56 ms 1732 KB Output is correct
86 Correct 81 ms 2140 KB Output is correct
87 Correct 66 ms 2124 KB Output is correct
88 Correct 68 ms 2152 KB Output is correct
89 Correct 82 ms 2188 KB Output is correct
90 Correct 70 ms 2140 KB Output is correct
91 Correct 172 ms 6968 KB Output is correct
92 Correct 147 ms 6936 KB Output is correct
93 Correct 175 ms 6972 KB Output is correct
94 Correct 205 ms 6980 KB Output is correct
95 Correct 159 ms 6860 KB Output is correct
96 Correct 266 ms 12324 KB Output is correct
97 Correct 287 ms 12364 KB Output is correct
98 Correct 275 ms 12420 KB Output is correct
99 Correct 308 ms 12364 KB Output is correct
100 Correct 284 ms 12492 KB Output is correct
101 Correct 235 ms 12448 KB Output is correct
102 Correct 243 ms 12448 KB Output is correct
103 Correct 255 ms 12408 KB Output is correct
104 Correct 248 ms 12444 KB Output is correct
105 Correct 274 ms 12540 KB Output is correct
106 Correct 288 ms 15192 KB Output is correct
107 Correct 305 ms 15100 KB Output is correct
108 Correct 295 ms 15156 KB Output is correct
109 Correct 316 ms 15128 KB Output is correct
110 Correct 330 ms 15092 KB Output is correct
111 Correct 288 ms 15260 KB Output is correct
112 Correct 291 ms 15188 KB Output is correct
113 Correct 289 ms 15216 KB Output is correct
114 Correct 297 ms 15160 KB Output is correct
115 Correct 322 ms 15216 KB Output is correct
116 Incorrect 2 ms 340 KB Output isn't correct
117 Halted 0 ms 0 KB -