답안 #526303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526303 2022-02-14T08:37:38 Z keta_tsimakuridze Diversity (CEOI21_diversity) C++14
64 / 100
138 ms 8616 KB
#include<bits/stdc++.h>
#define int long long
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7; // !
int t, n, a[N], c[N];
main(){
	int q;
	cin >> n >> q;
	for(int i = 1; i <= n; i++) cin >> a[i], c[a[i]]++;
	vector<int> x;
	for(int i = 1; i <= n; i++) {
		if(!c[a[i]]) continue;
		x.push_back(c[a[i]]);
		c[a[i]] = 0;
	}
	sort(x.rbegin(), x.rend());
	int t = 0;
	deque<int> dq;
	for(int i = 0; i < x.size(); i++) {
		if(t) dq.push_front(x[i]);
		else dq.push_back(x[i]);
		t ^= 1;
	}
	int p = 0, ans = x.size() * n * (n + 1) / 2;
	while(dq.size()) {
		int x = dq.front();
		dq.pop_front();
		ans -= (p * (p + 1) / 2);
		p += x;
		ans -= ((n - p) * (n - p + 1)) / 2;
	}
	cout << ans;
}

Compilation message

diversity.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
diversity.cpp: In function 'int main()':
diversity.cpp:22:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i = 0; i < x.size(); i++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 13 ms 992 KB Output is correct
5 Correct 26 ms 1840 KB Output is correct
6 Correct 41 ms 2528 KB Output is correct
7 Correct 54 ms 2628 KB Output is correct
8 Correct 44 ms 2628 KB Output is correct
9 Correct 41 ms 2596 KB Output is correct
10 Correct 40 ms 2628 KB Output is correct
11 Correct 39 ms 2596 KB Output is correct
12 Correct 40 ms 2540 KB Output is correct
13 Correct 39 ms 2628 KB Output is correct
14 Correct 40 ms 2584 KB Output is correct
15 Correct 40 ms 2556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 13 ms 992 KB Output is correct
5 Correct 26 ms 1840 KB Output is correct
6 Correct 41 ms 2528 KB Output is correct
7 Correct 54 ms 2628 KB Output is correct
8 Correct 44 ms 2628 KB Output is correct
9 Correct 41 ms 2596 KB Output is correct
10 Correct 40 ms 2628 KB Output is correct
11 Correct 39 ms 2596 KB Output is correct
12 Correct 40 ms 2540 KB Output is correct
13 Correct 39 ms 2628 KB Output is correct
14 Correct 40 ms 2584 KB Output is correct
15 Correct 40 ms 2556 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 16 ms 972 KB Output is correct
20 Correct 32 ms 1844 KB Output is correct
21 Correct 45 ms 2620 KB Output is correct
22 Correct 57 ms 2604 KB Output is correct
23 Correct 49 ms 2616 KB Output is correct
24 Correct 54 ms 2616 KB Output is correct
25 Correct 44 ms 2536 KB Output is correct
26 Correct 43 ms 2504 KB Output is correct
27 Correct 46 ms 2624 KB Output is correct
28 Correct 43 ms 2564 KB Output is correct
29 Correct 43 ms 2608 KB Output is correct
30 Correct 46 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 13 ms 992 KB Output is correct
5 Correct 26 ms 1840 KB Output is correct
6 Correct 41 ms 2528 KB Output is correct
7 Correct 54 ms 2628 KB Output is correct
8 Correct 44 ms 2628 KB Output is correct
9 Correct 41 ms 2596 KB Output is correct
10 Correct 40 ms 2628 KB Output is correct
11 Correct 39 ms 2596 KB Output is correct
12 Correct 40 ms 2540 KB Output is correct
13 Correct 39 ms 2628 KB Output is correct
14 Correct 40 ms 2584 KB Output is correct
15 Correct 40 ms 2556 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 16 ms 972 KB Output is correct
20 Correct 32 ms 1844 KB Output is correct
21 Correct 45 ms 2620 KB Output is correct
22 Correct 57 ms 2604 KB Output is correct
23 Correct 49 ms 2616 KB Output is correct
24 Correct 54 ms 2616 KB Output is correct
25 Correct 44 ms 2536 KB Output is correct
26 Correct 43 ms 2504 KB Output is correct
27 Correct 46 ms 2624 KB Output is correct
28 Correct 43 ms 2564 KB Output is correct
29 Correct 43 ms 2608 KB Output is correct
30 Correct 46 ms 2552 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 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 10 ms 700 KB Output is correct
38 Correct 10 ms 612 KB Output is correct
39 Correct 23 ms 1124 KB Output is correct
40 Correct 37 ms 1860 KB Output is correct
41 Correct 60 ms 2632 KB Output is correct
42 Correct 59 ms 2548 KB Output is correct
43 Correct 62 ms 2560 KB Output is correct
44 Correct 61 ms 2720 KB Output is correct
45 Correct 55 ms 2632 KB Output is correct
46 Correct 56 ms 2560 KB Output is correct
47 Correct 55 ms 2596 KB Output is correct
48 Correct 56 ms 2616 KB Output is correct
49 Correct 58 ms 2644 KB Output is correct
50 Correct 71 ms 2540 KB Output is correct
51 Correct 57 ms 2612 KB Output is correct
52 Correct 55 ms 2556 KB Output is correct
53 Correct 56 ms 2748 KB Output is correct
54 Correct 56 ms 2600 KB Output is correct
55 Correct 73 ms 2624 KB Output is correct
56 Correct 78 ms 2556 KB Output is correct
57 Correct 55 ms 2628 KB Output is correct
58 Correct 57 ms 2640 KB Output is correct
59 Correct 55 ms 2628 KB Output is correct
60 Correct 55 ms 2608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 13 ms 992 KB Output is correct
15 Correct 26 ms 1840 KB Output is correct
16 Correct 41 ms 2528 KB Output is correct
17 Correct 54 ms 2628 KB Output is correct
18 Correct 44 ms 2628 KB Output is correct
19 Correct 41 ms 2596 KB Output is correct
20 Correct 40 ms 2628 KB Output is correct
21 Correct 39 ms 2596 KB Output is correct
22 Correct 40 ms 2540 KB Output is correct
23 Correct 39 ms 2628 KB Output is correct
24 Correct 40 ms 2584 KB Output is correct
25 Correct 40 ms 2556 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 16 ms 972 KB Output is correct
30 Correct 32 ms 1844 KB Output is correct
31 Correct 45 ms 2620 KB Output is correct
32 Correct 57 ms 2604 KB Output is correct
33 Correct 49 ms 2616 KB Output is correct
34 Correct 54 ms 2616 KB Output is correct
35 Correct 44 ms 2536 KB Output is correct
36 Correct 43 ms 2504 KB Output is correct
37 Correct 46 ms 2624 KB Output is correct
38 Correct 43 ms 2564 KB Output is correct
39 Correct 43 ms 2608 KB Output is correct
40 Correct 46 ms 2552 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 2 ms 332 KB Output is correct
45 Correct 2 ms 332 KB Output is correct
46 Correct 2 ms 332 KB Output is correct
47 Correct 10 ms 700 KB Output is correct
48 Correct 10 ms 612 KB Output is correct
49 Correct 23 ms 1124 KB Output is correct
50 Correct 37 ms 1860 KB Output is correct
51 Correct 60 ms 2632 KB Output is correct
52 Correct 59 ms 2548 KB Output is correct
53 Correct 62 ms 2560 KB Output is correct
54 Correct 61 ms 2720 KB Output is correct
55 Correct 55 ms 2632 KB Output is correct
56 Correct 56 ms 2560 KB Output is correct
57 Correct 55 ms 2596 KB Output is correct
58 Correct 56 ms 2616 KB Output is correct
59 Correct 58 ms 2644 KB Output is correct
60 Correct 71 ms 2540 KB Output is correct
61 Correct 57 ms 2612 KB Output is correct
62 Correct 55 ms 2556 KB Output is correct
63 Correct 56 ms 2748 KB Output is correct
64 Correct 56 ms 2600 KB Output is correct
65 Correct 73 ms 2624 KB Output is correct
66 Correct 78 ms 2556 KB Output is correct
67 Correct 55 ms 2628 KB Output is correct
68 Correct 57 ms 2640 KB Output is correct
69 Correct 55 ms 2628 KB Output is correct
70 Correct 55 ms 2608 KB Output is correct
71 Correct 11 ms 652 KB Output is correct
72 Correct 16 ms 692 KB Output is correct
73 Correct 12 ms 696 KB Output is correct
74 Correct 12 ms 672 KB Output is correct
75 Correct 11 ms 716 KB Output is correct
76 Correct 26 ms 1092 KB Output is correct
77 Correct 22 ms 1092 KB Output is correct
78 Correct 22 ms 1228 KB Output is correct
79 Correct 21 ms 1228 KB Output is correct
80 Correct 22 ms 1092 KB Output is correct
81 Correct 44 ms 2104 KB Output is correct
82 Correct 43 ms 2120 KB Output is correct
83 Correct 47 ms 2056 KB Output is correct
84 Correct 46 ms 2092 KB Output is correct
85 Correct 46 ms 2068 KB Output is correct
86 Correct 47 ms 2372 KB Output is correct
87 Correct 48 ms 2288 KB Output is correct
88 Correct 48 ms 2384 KB Output is correct
89 Correct 49 ms 2356 KB Output is correct
90 Correct 51 ms 2320 KB Output is correct
91 Correct 109 ms 4916 KB Output is correct
92 Correct 81 ms 4940 KB Output is correct
93 Correct 78 ms 4916 KB Output is correct
94 Correct 88 ms 5144 KB Output is correct
95 Correct 79 ms 5000 KB Output is correct
96 Correct 92 ms 7300 KB Output is correct
97 Correct 98 ms 7344 KB Output is correct
98 Correct 91 ms 7516 KB Output is correct
99 Correct 87 ms 7348 KB Output is correct
100 Correct 88 ms 7364 KB Output is correct
101 Correct 86 ms 7408 KB Output is correct
102 Correct 117 ms 7348 KB Output is correct
103 Correct 106 ms 7348 KB Output is correct
104 Correct 86 ms 7304 KB Output is correct
105 Correct 88 ms 7348 KB Output is correct
106 Correct 88 ms 8516 KB Output is correct
107 Correct 88 ms 8516 KB Output is correct
108 Correct 138 ms 8568 KB Output is correct
109 Correct 92 ms 8588 KB Output is correct
110 Correct 95 ms 8608 KB Output is correct
111 Correct 91 ms 8488 KB Output is correct
112 Correct 101 ms 8496 KB Output is correct
113 Correct 103 ms 8604 KB Output is correct
114 Correct 88 ms 8552 KB Output is correct
115 Correct 89 ms 8616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 13 ms 992 KB Output is correct
15 Correct 26 ms 1840 KB Output is correct
16 Correct 41 ms 2528 KB Output is correct
17 Correct 54 ms 2628 KB Output is correct
18 Correct 44 ms 2628 KB Output is correct
19 Correct 41 ms 2596 KB Output is correct
20 Correct 40 ms 2628 KB Output is correct
21 Correct 39 ms 2596 KB Output is correct
22 Correct 40 ms 2540 KB Output is correct
23 Correct 39 ms 2628 KB Output is correct
24 Correct 40 ms 2584 KB Output is correct
25 Correct 40 ms 2556 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 16 ms 972 KB Output is correct
30 Correct 32 ms 1844 KB Output is correct
31 Correct 45 ms 2620 KB Output is correct
32 Correct 57 ms 2604 KB Output is correct
33 Correct 49 ms 2616 KB Output is correct
34 Correct 54 ms 2616 KB Output is correct
35 Correct 44 ms 2536 KB Output is correct
36 Correct 43 ms 2504 KB Output is correct
37 Correct 46 ms 2624 KB Output is correct
38 Correct 43 ms 2564 KB Output is correct
39 Correct 43 ms 2608 KB Output is correct
40 Correct 46 ms 2552 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 2 ms 332 KB Output is correct
45 Correct 2 ms 332 KB Output is correct
46 Correct 2 ms 332 KB Output is correct
47 Correct 10 ms 700 KB Output is correct
48 Correct 10 ms 612 KB Output is correct
49 Correct 23 ms 1124 KB Output is correct
50 Correct 37 ms 1860 KB Output is correct
51 Correct 60 ms 2632 KB Output is correct
52 Correct 59 ms 2548 KB Output is correct
53 Correct 62 ms 2560 KB Output is correct
54 Correct 61 ms 2720 KB Output is correct
55 Correct 55 ms 2632 KB Output is correct
56 Correct 56 ms 2560 KB Output is correct
57 Correct 55 ms 2596 KB Output is correct
58 Correct 56 ms 2616 KB Output is correct
59 Correct 58 ms 2644 KB Output is correct
60 Correct 71 ms 2540 KB Output is correct
61 Correct 57 ms 2612 KB Output is correct
62 Correct 55 ms 2556 KB Output is correct
63 Correct 56 ms 2748 KB Output is correct
64 Correct 56 ms 2600 KB Output is correct
65 Correct 73 ms 2624 KB Output is correct
66 Correct 78 ms 2556 KB Output is correct
67 Correct 55 ms 2628 KB Output is correct
68 Correct 57 ms 2640 KB Output is correct
69 Correct 55 ms 2628 KB Output is correct
70 Correct 55 ms 2608 KB Output is correct
71 Correct 11 ms 652 KB Output is correct
72 Correct 16 ms 692 KB Output is correct
73 Correct 12 ms 696 KB Output is correct
74 Correct 12 ms 672 KB Output is correct
75 Correct 11 ms 716 KB Output is correct
76 Correct 26 ms 1092 KB Output is correct
77 Correct 22 ms 1092 KB Output is correct
78 Correct 22 ms 1228 KB Output is correct
79 Correct 21 ms 1228 KB Output is correct
80 Correct 22 ms 1092 KB Output is correct
81 Correct 44 ms 2104 KB Output is correct
82 Correct 43 ms 2120 KB Output is correct
83 Correct 47 ms 2056 KB Output is correct
84 Correct 46 ms 2092 KB Output is correct
85 Correct 46 ms 2068 KB Output is correct
86 Correct 47 ms 2372 KB Output is correct
87 Correct 48 ms 2288 KB Output is correct
88 Correct 48 ms 2384 KB Output is correct
89 Correct 49 ms 2356 KB Output is correct
90 Correct 51 ms 2320 KB Output is correct
91 Correct 109 ms 4916 KB Output is correct
92 Correct 81 ms 4940 KB Output is correct
93 Correct 78 ms 4916 KB Output is correct
94 Correct 88 ms 5144 KB Output is correct
95 Correct 79 ms 5000 KB Output is correct
96 Correct 92 ms 7300 KB Output is correct
97 Correct 98 ms 7344 KB Output is correct
98 Correct 91 ms 7516 KB Output is correct
99 Correct 87 ms 7348 KB Output is correct
100 Correct 88 ms 7364 KB Output is correct
101 Correct 86 ms 7408 KB Output is correct
102 Correct 117 ms 7348 KB Output is correct
103 Correct 106 ms 7348 KB Output is correct
104 Correct 86 ms 7304 KB Output is correct
105 Correct 88 ms 7348 KB Output is correct
106 Correct 88 ms 8516 KB Output is correct
107 Correct 88 ms 8516 KB Output is correct
108 Correct 138 ms 8568 KB Output is correct
109 Correct 92 ms 8588 KB Output is correct
110 Correct 95 ms 8608 KB Output is correct
111 Correct 91 ms 8488 KB Output is correct
112 Correct 101 ms 8496 KB Output is correct
113 Correct 103 ms 8604 KB Output is correct
114 Correct 88 ms 8552 KB Output is correct
115 Correct 89 ms 8616 KB Output is correct
116 Incorrect 2 ms 332 KB Output isn't correct
117 Halted 0 ms 0 KB -