답안 #708157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708157 2023-03-11T07:19:51 Z vjudge1 Diversity (CEOI21_diversity) C++11
64 / 100
363 ms 17124 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;
  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;
  assert(q == 1 && L == 1 && R == n);

  LL ans = 0;
  sort(cnt.begin(), cnt.end());
  for (LL c : cnt) ans += c * (c + 1) / 2 + c * (n - c);
  LL l = 0, r = 0, gi = 1;
  // LL G[2], gi = 1;
  for (LL c : cnt) {
    // ans += G[gi] * (n - c - G[gi]), G[gi] += c;
    if (gi)
      ans += l * (n - c - l), l += c;
    else
      ans += r * (n - c - r), r += c;
    gi ^= 1;
  }
  cout << ans << '\n';
  return 0;
}
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 11 ms 724 KB Output is correct
5 Correct 17 ms 1476 KB Output is correct
6 Correct 25 ms 2132 KB Output is correct
7 Correct 20 ms 2004 KB Output is correct
8 Correct 25 ms 2000 KB Output is correct
9 Correct 23 ms 2136 KB Output is correct
10 Correct 24 ms 2128 KB Output is correct
11 Correct 24 ms 2124 KB Output is correct
12 Correct 24 ms 2124 KB Output is correct
13 Correct 24 ms 2124 KB Output is correct
14 Correct 25 ms 2132 KB Output is correct
15 Correct 31 ms 2004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 11 ms 724 KB Output is correct
5 Correct 17 ms 1476 KB Output is correct
6 Correct 25 ms 2132 KB Output is correct
7 Correct 20 ms 2004 KB Output is correct
8 Correct 25 ms 2000 KB Output is correct
9 Correct 23 ms 2136 KB Output is correct
10 Correct 24 ms 2128 KB Output is correct
11 Correct 24 ms 2124 KB Output is correct
12 Correct 24 ms 2124 KB Output is correct
13 Correct 24 ms 2124 KB Output is correct
14 Correct 25 ms 2132 KB Output is correct
15 Correct 31 ms 2004 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 10 ms 980 KB Output is correct
20 Correct 19 ms 1616 KB Output is correct
21 Correct 29 ms 2252 KB Output is correct
22 Correct 30 ms 2260 KB Output is correct
23 Correct 34 ms 2252 KB Output is correct
24 Correct 31 ms 2252 KB Output is correct
25 Correct 32 ms 2232 KB Output is correct
26 Correct 34 ms 2124 KB Output is correct
27 Correct 28 ms 2256 KB Output is correct
28 Correct 30 ms 2128 KB Output is correct
29 Correct 27 ms 2132 KB Output is correct
30 Correct 30 ms 2244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 11 ms 724 KB Output is correct
5 Correct 17 ms 1476 KB Output is correct
6 Correct 25 ms 2132 KB Output is correct
7 Correct 20 ms 2004 KB Output is correct
8 Correct 25 ms 2000 KB Output is correct
9 Correct 23 ms 2136 KB Output is correct
10 Correct 24 ms 2128 KB Output is correct
11 Correct 24 ms 2124 KB Output is correct
12 Correct 24 ms 2124 KB Output is correct
13 Correct 24 ms 2124 KB Output is correct
14 Correct 25 ms 2132 KB Output is correct
15 Correct 31 ms 2004 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 10 ms 980 KB Output is correct
20 Correct 19 ms 1616 KB Output is correct
21 Correct 29 ms 2252 KB Output is correct
22 Correct 30 ms 2260 KB Output is correct
23 Correct 34 ms 2252 KB Output is correct
24 Correct 31 ms 2252 KB Output is correct
25 Correct 32 ms 2232 KB Output is correct
26 Correct 34 ms 2124 KB Output is correct
27 Correct 28 ms 2256 KB Output is correct
28 Correct 30 ms 2128 KB Output is correct
29 Correct 27 ms 2132 KB Output is correct
30 Correct 30 ms 2244 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 320 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 9 ms 712 KB Output is correct
38 Correct 10 ms 672 KB Output is correct
39 Correct 22 ms 1108 KB Output is correct
40 Correct 45 ms 1872 KB Output is correct
41 Correct 58 ms 2684 KB Output is correct
42 Correct 57 ms 2668 KB Output is correct
43 Correct 52 ms 2636 KB Output is correct
44 Correct 57 ms 2680 KB Output is correct
45 Correct 53 ms 2680 KB Output is correct
46 Correct 54 ms 2688 KB Output is correct
47 Correct 52 ms 2636 KB Output is correct
48 Correct 55 ms 2552 KB Output is correct
49 Correct 53 ms 2552 KB Output is correct
50 Correct 56 ms 2684 KB Output is correct
51 Correct 55 ms 2636 KB Output is correct
52 Correct 58 ms 2668 KB Output is correct
53 Correct 56 ms 2668 KB Output is correct
54 Correct 54 ms 2760 KB Output is correct
55 Correct 57 ms 2680 KB Output is correct
56 Correct 58 ms 2672 KB Output is correct
57 Correct 60 ms 2556 KB Output is correct
58 Correct 57 ms 2636 KB Output is correct
59 Correct 54 ms 2644 KB Output is correct
60 Correct 60 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 11 ms 724 KB Output is correct
15 Correct 17 ms 1476 KB Output is correct
16 Correct 25 ms 2132 KB Output is correct
17 Correct 20 ms 2004 KB Output is correct
18 Correct 25 ms 2000 KB Output is correct
19 Correct 23 ms 2136 KB Output is correct
20 Correct 24 ms 2128 KB Output is correct
21 Correct 24 ms 2124 KB Output is correct
22 Correct 24 ms 2124 KB Output is correct
23 Correct 24 ms 2124 KB Output is correct
24 Correct 25 ms 2132 KB Output is correct
25 Correct 31 ms 2004 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 19 ms 1616 KB Output is correct
31 Correct 29 ms 2252 KB Output is correct
32 Correct 30 ms 2260 KB Output is correct
33 Correct 34 ms 2252 KB Output is correct
34 Correct 31 ms 2252 KB Output is correct
35 Correct 32 ms 2232 KB Output is correct
36 Correct 34 ms 2124 KB Output is correct
37 Correct 28 ms 2256 KB Output is correct
38 Correct 30 ms 2128 KB Output is correct
39 Correct 27 ms 2132 KB Output is correct
40 Correct 30 ms 2244 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 320 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 2 ms 332 KB Output is correct
46 Correct 3 ms 340 KB Output is correct
47 Correct 9 ms 712 KB Output is correct
48 Correct 10 ms 672 KB Output is correct
49 Correct 22 ms 1108 KB Output is correct
50 Correct 45 ms 1872 KB Output is correct
51 Correct 58 ms 2684 KB Output is correct
52 Correct 57 ms 2668 KB Output is correct
53 Correct 52 ms 2636 KB Output is correct
54 Correct 57 ms 2680 KB Output is correct
55 Correct 53 ms 2680 KB Output is correct
56 Correct 54 ms 2688 KB Output is correct
57 Correct 52 ms 2636 KB Output is correct
58 Correct 55 ms 2552 KB Output is correct
59 Correct 53 ms 2552 KB Output is correct
60 Correct 56 ms 2684 KB Output is correct
61 Correct 55 ms 2636 KB Output is correct
62 Correct 58 ms 2668 KB Output is correct
63 Correct 56 ms 2668 KB Output is correct
64 Correct 54 ms 2760 KB Output is correct
65 Correct 57 ms 2680 KB Output is correct
66 Correct 58 ms 2672 KB Output is correct
67 Correct 60 ms 2556 KB Output is correct
68 Correct 57 ms 2636 KB Output is correct
69 Correct 54 ms 2644 KB Output is correct
70 Correct 60 ms 2552 KB Output is correct
71 Correct 11 ms 852 KB Output is correct
72 Correct 11 ms 852 KB Output is correct
73 Correct 13 ms 820 KB Output is correct
74 Correct 12 ms 724 KB Output is correct
75 Correct 13 ms 724 KB Output is correct
76 Correct 28 ms 1364 KB Output is correct
77 Correct 28 ms 1424 KB Output is correct
78 Correct 25 ms 1412 KB Output is correct
79 Correct 25 ms 1416 KB Output is correct
80 Correct 25 ms 1420 KB Output is correct
81 Correct 60 ms 2576 KB Output is correct
82 Correct 59 ms 2604 KB Output is correct
83 Correct 62 ms 2600 KB Output is correct
84 Correct 77 ms 2608 KB Output is correct
85 Correct 56 ms 2564 KB Output is correct
86 Correct 70 ms 3156 KB Output is correct
87 Correct 73 ms 3216 KB Output is correct
88 Correct 70 ms 3228 KB Output is correct
89 Correct 75 ms 3144 KB Output is correct
90 Correct 78 ms 3256 KB Output is correct
91 Correct 160 ms 8640 KB Output is correct
92 Correct 157 ms 8704 KB Output is correct
93 Correct 169 ms 8696 KB Output is correct
94 Correct 221 ms 8608 KB Output is correct
95 Correct 166 ms 8780 KB Output is correct
96 Correct 279 ms 14428 KB Output is correct
97 Correct 320 ms 14296 KB Output is correct
98 Correct 249 ms 14448 KB Output is correct
99 Correct 264 ms 14308 KB Output is correct
100 Correct 283 ms 14340 KB Output is correct
101 Correct 326 ms 14328 KB Output is correct
102 Correct 281 ms 14388 KB Output is correct
103 Correct 324 ms 14264 KB Output is correct
104 Correct 271 ms 14340 KB Output is correct
105 Correct 316 ms 14228 KB Output is correct
106 Correct 308 ms 17124 KB Output is correct
107 Correct 359 ms 17124 KB Output is correct
108 Correct 297 ms 17112 KB Output is correct
109 Correct 363 ms 17084 KB Output is correct
110 Correct 298 ms 17080 KB Output is correct
111 Correct 354 ms 17100 KB Output is correct
112 Correct 292 ms 17108 KB Output is correct
113 Correct 313 ms 17116 KB Output is correct
114 Correct 311 ms 17112 KB Output is correct
115 Correct 297 ms 17116 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 11 ms 724 KB Output is correct
15 Correct 17 ms 1476 KB Output is correct
16 Correct 25 ms 2132 KB Output is correct
17 Correct 20 ms 2004 KB Output is correct
18 Correct 25 ms 2000 KB Output is correct
19 Correct 23 ms 2136 KB Output is correct
20 Correct 24 ms 2128 KB Output is correct
21 Correct 24 ms 2124 KB Output is correct
22 Correct 24 ms 2124 KB Output is correct
23 Correct 24 ms 2124 KB Output is correct
24 Correct 25 ms 2132 KB Output is correct
25 Correct 31 ms 2004 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 19 ms 1616 KB Output is correct
31 Correct 29 ms 2252 KB Output is correct
32 Correct 30 ms 2260 KB Output is correct
33 Correct 34 ms 2252 KB Output is correct
34 Correct 31 ms 2252 KB Output is correct
35 Correct 32 ms 2232 KB Output is correct
36 Correct 34 ms 2124 KB Output is correct
37 Correct 28 ms 2256 KB Output is correct
38 Correct 30 ms 2128 KB Output is correct
39 Correct 27 ms 2132 KB Output is correct
40 Correct 30 ms 2244 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 320 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 2 ms 332 KB Output is correct
46 Correct 3 ms 340 KB Output is correct
47 Correct 9 ms 712 KB Output is correct
48 Correct 10 ms 672 KB Output is correct
49 Correct 22 ms 1108 KB Output is correct
50 Correct 45 ms 1872 KB Output is correct
51 Correct 58 ms 2684 KB Output is correct
52 Correct 57 ms 2668 KB Output is correct
53 Correct 52 ms 2636 KB Output is correct
54 Correct 57 ms 2680 KB Output is correct
55 Correct 53 ms 2680 KB Output is correct
56 Correct 54 ms 2688 KB Output is correct
57 Correct 52 ms 2636 KB Output is correct
58 Correct 55 ms 2552 KB Output is correct
59 Correct 53 ms 2552 KB Output is correct
60 Correct 56 ms 2684 KB Output is correct
61 Correct 55 ms 2636 KB Output is correct
62 Correct 58 ms 2668 KB Output is correct
63 Correct 56 ms 2668 KB Output is correct
64 Correct 54 ms 2760 KB Output is correct
65 Correct 57 ms 2680 KB Output is correct
66 Correct 58 ms 2672 KB Output is correct
67 Correct 60 ms 2556 KB Output is correct
68 Correct 57 ms 2636 KB Output is correct
69 Correct 54 ms 2644 KB Output is correct
70 Correct 60 ms 2552 KB Output is correct
71 Correct 11 ms 852 KB Output is correct
72 Correct 11 ms 852 KB Output is correct
73 Correct 13 ms 820 KB Output is correct
74 Correct 12 ms 724 KB Output is correct
75 Correct 13 ms 724 KB Output is correct
76 Correct 28 ms 1364 KB Output is correct
77 Correct 28 ms 1424 KB Output is correct
78 Correct 25 ms 1412 KB Output is correct
79 Correct 25 ms 1416 KB Output is correct
80 Correct 25 ms 1420 KB Output is correct
81 Correct 60 ms 2576 KB Output is correct
82 Correct 59 ms 2604 KB Output is correct
83 Correct 62 ms 2600 KB Output is correct
84 Correct 77 ms 2608 KB Output is correct
85 Correct 56 ms 2564 KB Output is correct
86 Correct 70 ms 3156 KB Output is correct
87 Correct 73 ms 3216 KB Output is correct
88 Correct 70 ms 3228 KB Output is correct
89 Correct 75 ms 3144 KB Output is correct
90 Correct 78 ms 3256 KB Output is correct
91 Correct 160 ms 8640 KB Output is correct
92 Correct 157 ms 8704 KB Output is correct
93 Correct 169 ms 8696 KB Output is correct
94 Correct 221 ms 8608 KB Output is correct
95 Correct 166 ms 8780 KB Output is correct
96 Correct 279 ms 14428 KB Output is correct
97 Correct 320 ms 14296 KB Output is correct
98 Correct 249 ms 14448 KB Output is correct
99 Correct 264 ms 14308 KB Output is correct
100 Correct 283 ms 14340 KB Output is correct
101 Correct 326 ms 14328 KB Output is correct
102 Correct 281 ms 14388 KB Output is correct
103 Correct 324 ms 14264 KB Output is correct
104 Correct 271 ms 14340 KB Output is correct
105 Correct 316 ms 14228 KB Output is correct
106 Correct 308 ms 17124 KB Output is correct
107 Correct 359 ms 17124 KB Output is correct
108 Correct 297 ms 17112 KB Output is correct
109 Correct 363 ms 17084 KB Output is correct
110 Correct 298 ms 17080 KB Output is correct
111 Correct 354 ms 17100 KB Output is correct
112 Correct 292 ms 17108 KB Output is correct
113 Correct 313 ms 17116 KB Output is correct
114 Correct 311 ms 17112 KB Output is correct
115 Correct 297 ms 17116 KB Output is correct
116 Runtime error 3 ms 596 KB Execution killed with signal 6
117 Halted 0 ms 0 KB -