Submission #708063

# Submission time Handle Problem Language Result Execution time Memory
708063 2023-03-11T03:13:10 Z vjudge1 Diversity (CEOI21_diversity) C++11
64 / 100
379 ms 16260 KB
#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;
  using VI = vector<int>;
  VI A(n), cnt;
  map<int, int> M;
  for (int &a : A) cin >> a, M[a] = 0;

  int id = 0, k = M.size();
  for (auto &p : M) p.second = id++;
  cnt.resize(k);
  for (int &a : A) a = M[a], ++cnt[a];

  int L, R;
  cin >> L >> R;
  assert(q == 1 && L == 1 && R == n);

  ll ans = 0;
  for (int c : cnt) ans += (ll)c * (c + 1) / 2 + (ll)c * (n - c);
  sort(cnt.begin(), cnt.end());

  ll l = 0, r = 0, where = 1;
  for (int c : cnt) {
    if (where)
      ans += l * (n - c - l), l += c;
    else
      ans += r * (n - c - r), r += c;
    where ^= 1;
  }
  cout << ans << '\n';
  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 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
10 Correct 1 ms 212 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 340 KB Output is correct
4 Correct 10 ms 836 KB Output is correct
5 Correct 15 ms 1480 KB Output is correct
6 Correct 24 ms 2128 KB Output is correct
7 Correct 24 ms 2004 KB Output is correct
8 Correct 28 ms 2128 KB Output is correct
9 Correct 25 ms 2132 KB Output is correct
10 Correct 23 ms 2132 KB Output is correct
11 Correct 24 ms 2128 KB Output is correct
12 Correct 24 ms 2132 KB Output is correct
13 Correct 25 ms 2132 KB Output is correct
14 Correct 24 ms 2004 KB Output is correct
15 Correct 27 ms 2128 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 340 KB Output is correct
4 Correct 10 ms 836 KB Output is correct
5 Correct 15 ms 1480 KB Output is correct
6 Correct 24 ms 2128 KB Output is correct
7 Correct 24 ms 2004 KB Output is correct
8 Correct 28 ms 2128 KB Output is correct
9 Correct 25 ms 2132 KB Output is correct
10 Correct 23 ms 2132 KB Output is correct
11 Correct 24 ms 2128 KB Output is correct
12 Correct 24 ms 2132 KB Output is correct
13 Correct 25 ms 2132 KB Output is correct
14 Correct 24 ms 2004 KB Output is correct
15 Correct 27 ms 2128 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 11 ms 964 KB Output is correct
20 Correct 19 ms 1620 KB Output is correct
21 Correct 29 ms 2256 KB Output is correct
22 Correct 30 ms 2260 KB Output is correct
23 Correct 27 ms 2252 KB Output is correct
24 Correct 31 ms 2256 KB Output is correct
25 Correct 30 ms 2260 KB Output is correct
26 Correct 38 ms 2136 KB Output is correct
27 Correct 30 ms 2252 KB Output is correct
28 Correct 29 ms 2120 KB Output is correct
29 Correct 29 ms 2128 KB Output is correct
30 Correct 30 ms 2256 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 340 KB Output is correct
4 Correct 10 ms 836 KB Output is correct
5 Correct 15 ms 1480 KB Output is correct
6 Correct 24 ms 2128 KB Output is correct
7 Correct 24 ms 2004 KB Output is correct
8 Correct 28 ms 2128 KB Output is correct
9 Correct 25 ms 2132 KB Output is correct
10 Correct 23 ms 2132 KB Output is correct
11 Correct 24 ms 2128 KB Output is correct
12 Correct 24 ms 2132 KB Output is correct
13 Correct 25 ms 2132 KB Output is correct
14 Correct 24 ms 2004 KB Output is correct
15 Correct 27 ms 2128 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 11 ms 964 KB Output is correct
20 Correct 19 ms 1620 KB Output is correct
21 Correct 29 ms 2256 KB Output is correct
22 Correct 30 ms 2260 KB Output is correct
23 Correct 27 ms 2252 KB Output is correct
24 Correct 31 ms 2256 KB Output is correct
25 Correct 30 ms 2260 KB Output is correct
26 Correct 38 ms 2136 KB Output is correct
27 Correct 30 ms 2252 KB Output is correct
28 Correct 29 ms 2120 KB Output is correct
29 Correct 29 ms 2128 KB Output is correct
30 Correct 30 ms 2256 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 2 ms 340 KB Output is correct
35 Correct 2 ms 396 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 9 ms 712 KB Output is correct
38 Correct 10 ms 724 KB Output is correct
39 Correct 19 ms 1104 KB Output is correct
40 Correct 36 ms 1904 KB Output is correct
41 Correct 54 ms 2612 KB Output is correct
42 Correct 55 ms 2700 KB Output is correct
43 Correct 56 ms 2684 KB Output is correct
44 Correct 54 ms 2672 KB Output is correct
45 Correct 54 ms 2560 KB Output is correct
46 Correct 57 ms 2692 KB Output is correct
47 Correct 58 ms 2556 KB Output is correct
48 Correct 53 ms 2564 KB Output is correct
49 Correct 52 ms 2636 KB Output is correct
50 Correct 53 ms 2564 KB Output is correct
51 Correct 53 ms 2688 KB Output is correct
52 Correct 60 ms 2680 KB Output is correct
53 Correct 57 ms 2628 KB Output is correct
54 Correct 61 ms 2560 KB Output is correct
55 Correct 69 ms 2560 KB Output is correct
56 Correct 56 ms 2668 KB Output is correct
57 Correct 57 ms 2636 KB Output is correct
58 Correct 57 ms 2692 KB Output is correct
59 Correct 55 ms 2684 KB Output is correct
60 Correct 55 ms 2556 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 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 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 10 ms 836 KB Output is correct
15 Correct 15 ms 1480 KB Output is correct
16 Correct 24 ms 2128 KB Output is correct
17 Correct 24 ms 2004 KB Output is correct
18 Correct 28 ms 2128 KB Output is correct
19 Correct 25 ms 2132 KB Output is correct
20 Correct 23 ms 2132 KB Output is correct
21 Correct 24 ms 2128 KB Output is correct
22 Correct 24 ms 2132 KB Output is correct
23 Correct 25 ms 2132 KB Output is correct
24 Correct 24 ms 2004 KB Output is correct
25 Correct 27 ms 2128 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 11 ms 964 KB Output is correct
30 Correct 19 ms 1620 KB Output is correct
31 Correct 29 ms 2256 KB Output is correct
32 Correct 30 ms 2260 KB Output is correct
33 Correct 27 ms 2252 KB Output is correct
34 Correct 31 ms 2256 KB Output is correct
35 Correct 30 ms 2260 KB Output is correct
36 Correct 38 ms 2136 KB Output is correct
37 Correct 30 ms 2252 KB Output is correct
38 Correct 29 ms 2120 KB Output is correct
39 Correct 29 ms 2128 KB Output is correct
40 Correct 30 ms 2256 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 2 ms 340 KB Output is correct
45 Correct 2 ms 396 KB Output is correct
46 Correct 4 ms 340 KB Output is correct
47 Correct 9 ms 712 KB Output is correct
48 Correct 10 ms 724 KB Output is correct
49 Correct 19 ms 1104 KB Output is correct
50 Correct 36 ms 1904 KB Output is correct
51 Correct 54 ms 2612 KB Output is correct
52 Correct 55 ms 2700 KB Output is correct
53 Correct 56 ms 2684 KB Output is correct
54 Correct 54 ms 2672 KB Output is correct
55 Correct 54 ms 2560 KB Output is correct
56 Correct 57 ms 2692 KB Output is correct
57 Correct 58 ms 2556 KB Output is correct
58 Correct 53 ms 2564 KB Output is correct
59 Correct 52 ms 2636 KB Output is correct
60 Correct 53 ms 2564 KB Output is correct
61 Correct 53 ms 2688 KB Output is correct
62 Correct 60 ms 2680 KB Output is correct
63 Correct 57 ms 2628 KB Output is correct
64 Correct 61 ms 2560 KB Output is correct
65 Correct 69 ms 2560 KB Output is correct
66 Correct 56 ms 2668 KB Output is correct
67 Correct 57 ms 2636 KB Output is correct
68 Correct 57 ms 2692 KB Output is correct
69 Correct 55 ms 2684 KB Output is correct
70 Correct 55 ms 2556 KB Output is correct
71 Correct 14 ms 844 KB Output is correct
72 Correct 13 ms 724 KB Output is correct
73 Correct 11 ms 840 KB Output is correct
74 Correct 11 ms 724 KB Output is correct
75 Correct 11 ms 724 KB Output is correct
76 Correct 25 ms 1352 KB Output is correct
77 Correct 25 ms 1352 KB Output is correct
78 Correct 25 ms 1356 KB Output is correct
79 Correct 27 ms 1420 KB Output is correct
80 Correct 30 ms 1436 KB Output is correct
81 Correct 57 ms 2544 KB Output is correct
82 Correct 59 ms 2512 KB Output is correct
83 Correct 61 ms 2516 KB Output is correct
84 Correct 59 ms 2512 KB Output is correct
85 Correct 60 ms 2508 KB Output is correct
86 Correct 69 ms 3092 KB Output is correct
87 Correct 78 ms 3172 KB Output is correct
88 Correct 74 ms 3156 KB Output is correct
89 Correct 72 ms 3088 KB Output is correct
90 Correct 84 ms 3148 KB Output is correct
91 Correct 194 ms 8260 KB Output is correct
92 Correct 159 ms 8308 KB Output is correct
93 Correct 153 ms 8308 KB Output is correct
94 Correct 180 ms 8312 KB Output is correct
95 Correct 160 ms 8304 KB Output is correct
96 Correct 258 ms 13560 KB Output is correct
97 Correct 252 ms 13556 KB Output is correct
98 Correct 249 ms 13616 KB Output is correct
99 Correct 378 ms 13648 KB Output is correct
100 Correct 310 ms 13448 KB Output is correct
101 Correct 379 ms 13444 KB Output is correct
102 Correct 317 ms 13464 KB Output is correct
103 Correct 238 ms 13488 KB Output is correct
104 Correct 255 ms 13508 KB Output is correct
105 Correct 237 ms 13560 KB Output is correct
106 Correct 305 ms 16140 KB Output is correct
107 Correct 326 ms 16140 KB Output is correct
108 Correct 352 ms 16040 KB Output is correct
109 Correct 296 ms 16128 KB Output is correct
110 Correct 323 ms 16164 KB Output is correct
111 Correct 315 ms 16260 KB Output is correct
112 Correct 331 ms 16140 KB Output is correct
113 Correct 281 ms 16136 KB Output is correct
114 Correct 312 ms 16140 KB Output is correct
115 Correct 355 ms 16076 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 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 0 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 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 10 ms 836 KB Output is correct
15 Correct 15 ms 1480 KB Output is correct
16 Correct 24 ms 2128 KB Output is correct
17 Correct 24 ms 2004 KB Output is correct
18 Correct 28 ms 2128 KB Output is correct
19 Correct 25 ms 2132 KB Output is correct
20 Correct 23 ms 2132 KB Output is correct
21 Correct 24 ms 2128 KB Output is correct
22 Correct 24 ms 2132 KB Output is correct
23 Correct 25 ms 2132 KB Output is correct
24 Correct 24 ms 2004 KB Output is correct
25 Correct 27 ms 2128 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 11 ms 964 KB Output is correct
30 Correct 19 ms 1620 KB Output is correct
31 Correct 29 ms 2256 KB Output is correct
32 Correct 30 ms 2260 KB Output is correct
33 Correct 27 ms 2252 KB Output is correct
34 Correct 31 ms 2256 KB Output is correct
35 Correct 30 ms 2260 KB Output is correct
36 Correct 38 ms 2136 KB Output is correct
37 Correct 30 ms 2252 KB Output is correct
38 Correct 29 ms 2120 KB Output is correct
39 Correct 29 ms 2128 KB Output is correct
40 Correct 30 ms 2256 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 2 ms 340 KB Output is correct
45 Correct 2 ms 396 KB Output is correct
46 Correct 4 ms 340 KB Output is correct
47 Correct 9 ms 712 KB Output is correct
48 Correct 10 ms 724 KB Output is correct
49 Correct 19 ms 1104 KB Output is correct
50 Correct 36 ms 1904 KB Output is correct
51 Correct 54 ms 2612 KB Output is correct
52 Correct 55 ms 2700 KB Output is correct
53 Correct 56 ms 2684 KB Output is correct
54 Correct 54 ms 2672 KB Output is correct
55 Correct 54 ms 2560 KB Output is correct
56 Correct 57 ms 2692 KB Output is correct
57 Correct 58 ms 2556 KB Output is correct
58 Correct 53 ms 2564 KB Output is correct
59 Correct 52 ms 2636 KB Output is correct
60 Correct 53 ms 2564 KB Output is correct
61 Correct 53 ms 2688 KB Output is correct
62 Correct 60 ms 2680 KB Output is correct
63 Correct 57 ms 2628 KB Output is correct
64 Correct 61 ms 2560 KB Output is correct
65 Correct 69 ms 2560 KB Output is correct
66 Correct 56 ms 2668 KB Output is correct
67 Correct 57 ms 2636 KB Output is correct
68 Correct 57 ms 2692 KB Output is correct
69 Correct 55 ms 2684 KB Output is correct
70 Correct 55 ms 2556 KB Output is correct
71 Correct 14 ms 844 KB Output is correct
72 Correct 13 ms 724 KB Output is correct
73 Correct 11 ms 840 KB Output is correct
74 Correct 11 ms 724 KB Output is correct
75 Correct 11 ms 724 KB Output is correct
76 Correct 25 ms 1352 KB Output is correct
77 Correct 25 ms 1352 KB Output is correct
78 Correct 25 ms 1356 KB Output is correct
79 Correct 27 ms 1420 KB Output is correct
80 Correct 30 ms 1436 KB Output is correct
81 Correct 57 ms 2544 KB Output is correct
82 Correct 59 ms 2512 KB Output is correct
83 Correct 61 ms 2516 KB Output is correct
84 Correct 59 ms 2512 KB Output is correct
85 Correct 60 ms 2508 KB Output is correct
86 Correct 69 ms 3092 KB Output is correct
87 Correct 78 ms 3172 KB Output is correct
88 Correct 74 ms 3156 KB Output is correct
89 Correct 72 ms 3088 KB Output is correct
90 Correct 84 ms 3148 KB Output is correct
91 Correct 194 ms 8260 KB Output is correct
92 Correct 159 ms 8308 KB Output is correct
93 Correct 153 ms 8308 KB Output is correct
94 Correct 180 ms 8312 KB Output is correct
95 Correct 160 ms 8304 KB Output is correct
96 Correct 258 ms 13560 KB Output is correct
97 Correct 252 ms 13556 KB Output is correct
98 Correct 249 ms 13616 KB Output is correct
99 Correct 378 ms 13648 KB Output is correct
100 Correct 310 ms 13448 KB Output is correct
101 Correct 379 ms 13444 KB Output is correct
102 Correct 317 ms 13464 KB Output is correct
103 Correct 238 ms 13488 KB Output is correct
104 Correct 255 ms 13508 KB Output is correct
105 Correct 237 ms 13560 KB Output is correct
106 Correct 305 ms 16140 KB Output is correct
107 Correct 326 ms 16140 KB Output is correct
108 Correct 352 ms 16040 KB Output is correct
109 Correct 296 ms 16128 KB Output is correct
110 Correct 323 ms 16164 KB Output is correct
111 Correct 315 ms 16260 KB Output is correct
112 Correct 331 ms 16140 KB Output is correct
113 Correct 281 ms 16136 KB Output is correct
114 Correct 312 ms 16140 KB Output is correct
115 Correct 355 ms 16076 KB Output is correct
116 Runtime error 2 ms 596 KB Execution killed with signal 6
117 Halted 0 ms 0 KB -