답안 #871323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871323 2023-11-10T14:56:57 Z Trisanu_Das Diversity (CEOI21_diversity) C++17
64 / 100
77 ms 11060 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 3e5 + 5, mod = 1e9 + 7;
int t, n, a[300005], c[300005];

signed 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: In function 'int main()':
diversity.cpp:21: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]
   21 |  for(int i = 0; i < x.size(); i++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 11 ms 2492 KB Output is correct
5 Correct 20 ms 2396 KB Output is correct
6 Correct 34 ms 2640 KB Output is correct
7 Correct 31 ms 2908 KB Output is correct
8 Correct 33 ms 2680 KB Output is correct
9 Correct 33 ms 2648 KB Output is correct
10 Correct 33 ms 2644 KB Output is correct
11 Correct 32 ms 2684 KB Output is correct
12 Correct 40 ms 2780 KB Output is correct
13 Correct 32 ms 2740 KB Output is correct
14 Correct 35 ms 2740 KB Output is correct
15 Correct 32 ms 2736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 11 ms 2492 KB Output is correct
5 Correct 20 ms 2396 KB Output is correct
6 Correct 34 ms 2640 KB Output is correct
7 Correct 31 ms 2908 KB Output is correct
8 Correct 33 ms 2680 KB Output is correct
9 Correct 33 ms 2648 KB Output is correct
10 Correct 33 ms 2644 KB Output is correct
11 Correct 32 ms 2684 KB Output is correct
12 Correct 40 ms 2780 KB Output is correct
13 Correct 32 ms 2740 KB Output is correct
14 Correct 35 ms 2740 KB Output is correct
15 Correct 32 ms 2736 KB Output is correct
16 Correct 0 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 12 ms 2396 KB Output is correct
20 Correct 24 ms 2396 KB Output is correct
21 Correct 36 ms 2644 KB Output is correct
22 Correct 36 ms 2640 KB Output is correct
23 Correct 36 ms 2744 KB Output is correct
24 Correct 35 ms 2644 KB Output is correct
25 Correct 35 ms 2908 KB Output is correct
26 Correct 34 ms 2908 KB Output is correct
27 Correct 36 ms 2648 KB Output is correct
28 Correct 34 ms 2652 KB Output is correct
29 Correct 35 ms 2736 KB Output is correct
30 Correct 36 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 11 ms 2492 KB Output is correct
5 Correct 20 ms 2396 KB Output is correct
6 Correct 34 ms 2640 KB Output is correct
7 Correct 31 ms 2908 KB Output is correct
8 Correct 33 ms 2680 KB Output is correct
9 Correct 33 ms 2648 KB Output is correct
10 Correct 33 ms 2644 KB Output is correct
11 Correct 32 ms 2684 KB Output is correct
12 Correct 40 ms 2780 KB Output is correct
13 Correct 32 ms 2740 KB Output is correct
14 Correct 35 ms 2740 KB Output is correct
15 Correct 32 ms 2736 KB Output is correct
16 Correct 0 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 12 ms 2396 KB Output is correct
20 Correct 24 ms 2396 KB Output is correct
21 Correct 36 ms 2644 KB Output is correct
22 Correct 36 ms 2640 KB Output is correct
23 Correct 36 ms 2744 KB Output is correct
24 Correct 35 ms 2644 KB Output is correct
25 Correct 35 ms 2908 KB Output is correct
26 Correct 34 ms 2908 KB Output is correct
27 Correct 36 ms 2648 KB Output is correct
28 Correct 34 ms 2652 KB Output is correct
29 Correct 35 ms 2736 KB Output is correct
30 Correct 36 ms 2908 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2528 KB Output is correct
36 Correct 3 ms 2392 KB Output is correct
37 Correct 8 ms 2504 KB Output is correct
38 Correct 8 ms 2652 KB Output is correct
39 Correct 15 ms 2864 KB Output is correct
40 Correct 35 ms 3116 KB Output is correct
41 Correct 43 ms 3924 KB Output is correct
42 Correct 43 ms 4000 KB Output is correct
43 Correct 43 ms 3920 KB Output is correct
44 Correct 43 ms 3924 KB Output is correct
45 Correct 47 ms 4012 KB Output is correct
46 Correct 43 ms 3920 KB Output is correct
47 Correct 43 ms 3876 KB Output is correct
48 Correct 43 ms 4008 KB Output is correct
49 Correct 43 ms 3920 KB Output is correct
50 Correct 43 ms 3888 KB Output is correct
51 Correct 47 ms 4008 KB Output is correct
52 Correct 43 ms 4028 KB Output is correct
53 Correct 43 ms 3920 KB Output is correct
54 Correct 46 ms 3924 KB Output is correct
55 Correct 42 ms 3888 KB Output is correct
56 Correct 43 ms 3924 KB Output is correct
57 Correct 44 ms 3872 KB Output is correct
58 Correct 43 ms 3872 KB Output is correct
59 Correct 43 ms 3924 KB Output is correct
60 Correct 43 ms 3924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 11 ms 2492 KB Output is correct
15 Correct 20 ms 2396 KB Output is correct
16 Correct 34 ms 2640 KB Output is correct
17 Correct 31 ms 2908 KB Output is correct
18 Correct 33 ms 2680 KB Output is correct
19 Correct 33 ms 2648 KB Output is correct
20 Correct 33 ms 2644 KB Output is correct
21 Correct 32 ms 2684 KB Output is correct
22 Correct 40 ms 2780 KB Output is correct
23 Correct 32 ms 2740 KB Output is correct
24 Correct 35 ms 2740 KB Output is correct
25 Correct 32 ms 2736 KB Output is correct
26 Correct 0 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 12 ms 2396 KB Output is correct
30 Correct 24 ms 2396 KB Output is correct
31 Correct 36 ms 2644 KB Output is correct
32 Correct 36 ms 2640 KB Output is correct
33 Correct 36 ms 2744 KB Output is correct
34 Correct 35 ms 2644 KB Output is correct
35 Correct 35 ms 2908 KB Output is correct
36 Correct 34 ms 2908 KB Output is correct
37 Correct 36 ms 2648 KB Output is correct
38 Correct 34 ms 2652 KB Output is correct
39 Correct 35 ms 2736 KB Output is correct
40 Correct 36 ms 2908 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 2 ms 2528 KB Output is correct
46 Correct 3 ms 2392 KB Output is correct
47 Correct 8 ms 2504 KB Output is correct
48 Correct 8 ms 2652 KB Output is correct
49 Correct 15 ms 2864 KB Output is correct
50 Correct 35 ms 3116 KB Output is correct
51 Correct 43 ms 3924 KB Output is correct
52 Correct 43 ms 4000 KB Output is correct
53 Correct 43 ms 3920 KB Output is correct
54 Correct 43 ms 3924 KB Output is correct
55 Correct 47 ms 4012 KB Output is correct
56 Correct 43 ms 3920 KB Output is correct
57 Correct 43 ms 3876 KB Output is correct
58 Correct 43 ms 4008 KB Output is correct
59 Correct 43 ms 3920 KB Output is correct
60 Correct 43 ms 3888 KB Output is correct
61 Correct 47 ms 4008 KB Output is correct
62 Correct 43 ms 4028 KB Output is correct
63 Correct 43 ms 3920 KB Output is correct
64 Correct 46 ms 3924 KB Output is correct
65 Correct 42 ms 3888 KB Output is correct
66 Correct 43 ms 3924 KB Output is correct
67 Correct 44 ms 3872 KB Output is correct
68 Correct 43 ms 3872 KB Output is correct
69 Correct 43 ms 3924 KB Output is correct
70 Correct 43 ms 3924 KB Output is correct
71 Correct 9 ms 2652 KB Output is correct
72 Correct 9 ms 2724 KB Output is correct
73 Correct 8 ms 2652 KB Output is correct
74 Correct 8 ms 2904 KB Output is correct
75 Correct 8 ms 2648 KB Output is correct
76 Correct 17 ms 2904 KB Output is correct
77 Correct 18 ms 2904 KB Output is correct
78 Correct 17 ms 2908 KB Output is correct
79 Correct 17 ms 2908 KB Output is correct
80 Correct 17 ms 2908 KB Output is correct
81 Correct 35 ms 3700 KB Output is correct
82 Correct 35 ms 3696 KB Output is correct
83 Correct 39 ms 3672 KB Output is correct
84 Correct 35 ms 3512 KB Output is correct
85 Correct 35 ms 3664 KB Output is correct
86 Correct 37 ms 3920 KB Output is correct
87 Correct 37 ms 3924 KB Output is correct
88 Correct 48 ms 3920 KB Output is correct
89 Correct 38 ms 4024 KB Output is correct
90 Correct 44 ms 4020 KB Output is correct
91 Correct 63 ms 8252 KB Output is correct
92 Correct 62 ms 8392 KB Output is correct
93 Correct 61 ms 8260 KB Output is correct
94 Correct 62 ms 8388 KB Output is correct
95 Correct 62 ms 8264 KB Output is correct
96 Correct 68 ms 10176 KB Output is correct
97 Correct 69 ms 10040 KB Output is correct
98 Correct 69 ms 10180 KB Output is correct
99 Correct 69 ms 10180 KB Output is correct
100 Correct 75 ms 10292 KB Output is correct
101 Correct 72 ms 10040 KB Output is correct
102 Correct 69 ms 10176 KB Output is correct
103 Correct 70 ms 10184 KB Output is correct
104 Correct 68 ms 10036 KB Output is correct
105 Correct 77 ms 10176 KB Output is correct
106 Correct 73 ms 10936 KB Output is correct
107 Correct 69 ms 10944 KB Output is correct
108 Correct 68 ms 11060 KB Output is correct
109 Correct 69 ms 10948 KB Output is correct
110 Correct 69 ms 10820 KB Output is correct
111 Correct 69 ms 10948 KB Output is correct
112 Correct 69 ms 10948 KB Output is correct
113 Correct 68 ms 10944 KB Output is correct
114 Correct 68 ms 10944 KB Output is correct
115 Correct 69 ms 10944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 11 ms 2492 KB Output is correct
15 Correct 20 ms 2396 KB Output is correct
16 Correct 34 ms 2640 KB Output is correct
17 Correct 31 ms 2908 KB Output is correct
18 Correct 33 ms 2680 KB Output is correct
19 Correct 33 ms 2648 KB Output is correct
20 Correct 33 ms 2644 KB Output is correct
21 Correct 32 ms 2684 KB Output is correct
22 Correct 40 ms 2780 KB Output is correct
23 Correct 32 ms 2740 KB Output is correct
24 Correct 35 ms 2740 KB Output is correct
25 Correct 32 ms 2736 KB Output is correct
26 Correct 0 ms 2392 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 12 ms 2396 KB Output is correct
30 Correct 24 ms 2396 KB Output is correct
31 Correct 36 ms 2644 KB Output is correct
32 Correct 36 ms 2640 KB Output is correct
33 Correct 36 ms 2744 KB Output is correct
34 Correct 35 ms 2644 KB Output is correct
35 Correct 35 ms 2908 KB Output is correct
36 Correct 34 ms 2908 KB Output is correct
37 Correct 36 ms 2648 KB Output is correct
38 Correct 34 ms 2652 KB Output is correct
39 Correct 35 ms 2736 KB Output is correct
40 Correct 36 ms 2908 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 2 ms 2528 KB Output is correct
46 Correct 3 ms 2392 KB Output is correct
47 Correct 8 ms 2504 KB Output is correct
48 Correct 8 ms 2652 KB Output is correct
49 Correct 15 ms 2864 KB Output is correct
50 Correct 35 ms 3116 KB Output is correct
51 Correct 43 ms 3924 KB Output is correct
52 Correct 43 ms 4000 KB Output is correct
53 Correct 43 ms 3920 KB Output is correct
54 Correct 43 ms 3924 KB Output is correct
55 Correct 47 ms 4012 KB Output is correct
56 Correct 43 ms 3920 KB Output is correct
57 Correct 43 ms 3876 KB Output is correct
58 Correct 43 ms 4008 KB Output is correct
59 Correct 43 ms 3920 KB Output is correct
60 Correct 43 ms 3888 KB Output is correct
61 Correct 47 ms 4008 KB Output is correct
62 Correct 43 ms 4028 KB Output is correct
63 Correct 43 ms 3920 KB Output is correct
64 Correct 46 ms 3924 KB Output is correct
65 Correct 42 ms 3888 KB Output is correct
66 Correct 43 ms 3924 KB Output is correct
67 Correct 44 ms 3872 KB Output is correct
68 Correct 43 ms 3872 KB Output is correct
69 Correct 43 ms 3924 KB Output is correct
70 Correct 43 ms 3924 KB Output is correct
71 Correct 9 ms 2652 KB Output is correct
72 Correct 9 ms 2724 KB Output is correct
73 Correct 8 ms 2652 KB Output is correct
74 Correct 8 ms 2904 KB Output is correct
75 Correct 8 ms 2648 KB Output is correct
76 Correct 17 ms 2904 KB Output is correct
77 Correct 18 ms 2904 KB Output is correct
78 Correct 17 ms 2908 KB Output is correct
79 Correct 17 ms 2908 KB Output is correct
80 Correct 17 ms 2908 KB Output is correct
81 Correct 35 ms 3700 KB Output is correct
82 Correct 35 ms 3696 KB Output is correct
83 Correct 39 ms 3672 KB Output is correct
84 Correct 35 ms 3512 KB Output is correct
85 Correct 35 ms 3664 KB Output is correct
86 Correct 37 ms 3920 KB Output is correct
87 Correct 37 ms 3924 KB Output is correct
88 Correct 48 ms 3920 KB Output is correct
89 Correct 38 ms 4024 KB Output is correct
90 Correct 44 ms 4020 KB Output is correct
91 Correct 63 ms 8252 KB Output is correct
92 Correct 62 ms 8392 KB Output is correct
93 Correct 61 ms 8260 KB Output is correct
94 Correct 62 ms 8388 KB Output is correct
95 Correct 62 ms 8264 KB Output is correct
96 Correct 68 ms 10176 KB Output is correct
97 Correct 69 ms 10040 KB Output is correct
98 Correct 69 ms 10180 KB Output is correct
99 Correct 69 ms 10180 KB Output is correct
100 Correct 75 ms 10292 KB Output is correct
101 Correct 72 ms 10040 KB Output is correct
102 Correct 69 ms 10176 KB Output is correct
103 Correct 70 ms 10184 KB Output is correct
104 Correct 68 ms 10036 KB Output is correct
105 Correct 77 ms 10176 KB Output is correct
106 Correct 73 ms 10936 KB Output is correct
107 Correct 69 ms 10944 KB Output is correct
108 Correct 68 ms 11060 KB Output is correct
109 Correct 69 ms 10948 KB Output is correct
110 Correct 69 ms 10820 KB Output is correct
111 Correct 69 ms 10948 KB Output is correct
112 Correct 69 ms 10948 KB Output is correct
113 Correct 68 ms 10944 KB Output is correct
114 Correct 68 ms 10944 KB Output is correct
115 Correct 69 ms 10944 KB Output is correct
116 Incorrect 2 ms 2392 KB Output isn't correct
117 Halted 0 ms 0 KB -