답안 #944865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944865 2024-03-13T06:53:06 Z Halym2007 Diversity (CEOI21_diversity) C++17
64 / 100
187 ms 20880 KB
#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define pb push_back
#define ll long long
#define ss second
const int N = 3e5 + 5;
int n, q, b[N], a[N];
ll jog;
deque <int> v, qq;
map <int, int> m;
ll p[N];
int main () {
//	freopen ("input1.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) {
		cin >> b[i];
	}
	for (int i = 1; i <= n; ++i) {
		m[b[i]]++;
	}
	for (auto i : m) {
		qq.pb (i.ss);
	}
	sort(qq.rbegin(), qq.rend());
	int tr = 0;
	for (int i : qq) {
		if (!tr) {
			v.pb (i);
		}
		else { 
			v.push_front(i);
		}
		tr ^= 1;
	}
	int git = (int)v.sz;
	ll sum1 = 0;
	p[git - 1] = v[git - 1];
	for (int i = git - 2; i >= 0; i--) {
		p[i] += p[i + 1] + v[i];
	}
	for (int i = git - 1; i >= 0; i--) {
		jog += (sum1 + p[i + 1]) * v[i];
		jog += (v[i] + 1LL) * v[i] / 2;
		sum1 += p[i];
	}	
	int l, r;
	cin >> l >> r;
	cout << jog;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 2648 KB Output is correct
5 Correct 11 ms 2908 KB Output is correct
6 Correct 18 ms 3420 KB Output is correct
7 Correct 16 ms 3396 KB Output is correct
8 Correct 16 ms 3420 KB Output is correct
9 Correct 17 ms 3420 KB Output is correct
10 Correct 17 ms 3420 KB Output is correct
11 Correct 17 ms 3384 KB Output is correct
12 Correct 17 ms 3672 KB Output is correct
13 Correct 17 ms 3420 KB Output is correct
14 Correct 17 ms 3420 KB Output is correct
15 Correct 17 ms 3576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 2648 KB Output is correct
5 Correct 11 ms 2908 KB Output is correct
6 Correct 18 ms 3420 KB Output is correct
7 Correct 16 ms 3396 KB Output is correct
8 Correct 16 ms 3420 KB Output is correct
9 Correct 17 ms 3420 KB Output is correct
10 Correct 17 ms 3420 KB Output is correct
11 Correct 17 ms 3384 KB Output is correct
12 Correct 17 ms 3672 KB Output is correct
13 Correct 17 ms 3420 KB Output is correct
14 Correct 17 ms 3420 KB Output is correct
15 Correct 17 ms 3576 KB Output is correct
16 Correct 1 ms 2492 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 8 ms 2784 KB Output is correct
20 Correct 14 ms 2908 KB Output is correct
21 Correct 19 ms 3676 KB Output is correct
22 Correct 19 ms 3676 KB Output is correct
23 Correct 19 ms 3928 KB Output is correct
24 Correct 19 ms 3672 KB Output is correct
25 Correct 19 ms 3676 KB Output is correct
26 Correct 20 ms 3660 KB Output is correct
27 Correct 23 ms 3932 KB Output is correct
28 Correct 19 ms 3420 KB Output is correct
29 Correct 20 ms 3676 KB Output is correct
30 Correct 20 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 2648 KB Output is correct
5 Correct 11 ms 2908 KB Output is correct
6 Correct 18 ms 3420 KB Output is correct
7 Correct 16 ms 3396 KB Output is correct
8 Correct 16 ms 3420 KB Output is correct
9 Correct 17 ms 3420 KB Output is correct
10 Correct 17 ms 3420 KB Output is correct
11 Correct 17 ms 3384 KB Output is correct
12 Correct 17 ms 3672 KB Output is correct
13 Correct 17 ms 3420 KB Output is correct
14 Correct 17 ms 3420 KB Output is correct
15 Correct 17 ms 3576 KB Output is correct
16 Correct 1 ms 2492 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 8 ms 2784 KB Output is correct
20 Correct 14 ms 2908 KB Output is correct
21 Correct 19 ms 3676 KB Output is correct
22 Correct 19 ms 3676 KB Output is correct
23 Correct 19 ms 3928 KB Output is correct
24 Correct 19 ms 3672 KB Output is correct
25 Correct 19 ms 3676 KB Output is correct
26 Correct 20 ms 3660 KB Output is correct
27 Correct 23 ms 3932 KB Output is correct
28 Correct 19 ms 3420 KB Output is correct
29 Correct 20 ms 3676 KB Output is correct
30 Correct 20 ms 3676 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 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 2396 KB Output is correct
36 Correct 2 ms 2396 KB Output is correct
37 Correct 5 ms 2736 KB Output is correct
38 Correct 6 ms 2652 KB Output is correct
39 Correct 11 ms 2908 KB Output is correct
40 Correct 22 ms 3148 KB Output is correct
41 Correct 31 ms 4112 KB Output is correct
42 Correct 31 ms 3932 KB Output is correct
43 Correct 30 ms 3932 KB Output is correct
44 Correct 30 ms 3932 KB Output is correct
45 Correct 30 ms 3932 KB Output is correct
46 Correct 31 ms 4128 KB Output is correct
47 Correct 31 ms 4128 KB Output is correct
48 Correct 30 ms 4132 KB Output is correct
49 Correct 30 ms 3932 KB Output is correct
50 Correct 30 ms 3932 KB Output is correct
51 Correct 38 ms 4132 KB Output is correct
52 Correct 30 ms 4132 KB Output is correct
53 Correct 30 ms 4040 KB Output is correct
54 Correct 30 ms 4132 KB Output is correct
55 Correct 30 ms 3932 KB Output is correct
56 Correct 30 ms 4120 KB Output is correct
57 Correct 30 ms 3928 KB Output is correct
58 Correct 30 ms 4124 KB Output is correct
59 Correct 30 ms 3928 KB Output is correct
60 Correct 30 ms 3932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 6 ms 2648 KB Output is correct
15 Correct 11 ms 2908 KB Output is correct
16 Correct 18 ms 3420 KB Output is correct
17 Correct 16 ms 3396 KB Output is correct
18 Correct 16 ms 3420 KB Output is correct
19 Correct 17 ms 3420 KB Output is correct
20 Correct 17 ms 3420 KB Output is correct
21 Correct 17 ms 3384 KB Output is correct
22 Correct 17 ms 3672 KB Output is correct
23 Correct 17 ms 3420 KB Output is correct
24 Correct 17 ms 3420 KB Output is correct
25 Correct 17 ms 3576 KB Output is correct
26 Correct 1 ms 2492 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 8 ms 2784 KB Output is correct
30 Correct 14 ms 2908 KB Output is correct
31 Correct 19 ms 3676 KB Output is correct
32 Correct 19 ms 3676 KB Output is correct
33 Correct 19 ms 3928 KB Output is correct
34 Correct 19 ms 3672 KB Output is correct
35 Correct 19 ms 3676 KB Output is correct
36 Correct 20 ms 3660 KB Output is correct
37 Correct 23 ms 3932 KB Output is correct
38 Correct 19 ms 3420 KB Output is correct
39 Correct 20 ms 3676 KB Output is correct
40 Correct 20 ms 3676 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 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 2396 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 5 ms 2736 KB Output is correct
48 Correct 6 ms 2652 KB Output is correct
49 Correct 11 ms 2908 KB Output is correct
50 Correct 22 ms 3148 KB Output is correct
51 Correct 31 ms 4112 KB Output is correct
52 Correct 31 ms 3932 KB Output is correct
53 Correct 30 ms 3932 KB Output is correct
54 Correct 30 ms 3932 KB Output is correct
55 Correct 30 ms 3932 KB Output is correct
56 Correct 31 ms 4128 KB Output is correct
57 Correct 31 ms 4128 KB Output is correct
58 Correct 30 ms 4132 KB Output is correct
59 Correct 30 ms 3932 KB Output is correct
60 Correct 30 ms 3932 KB Output is correct
61 Correct 38 ms 4132 KB Output is correct
62 Correct 30 ms 4132 KB Output is correct
63 Correct 30 ms 4040 KB Output is correct
64 Correct 30 ms 4132 KB Output is correct
65 Correct 30 ms 3932 KB Output is correct
66 Correct 30 ms 4120 KB Output is correct
67 Correct 30 ms 3928 KB Output is correct
68 Correct 30 ms 4124 KB Output is correct
69 Correct 30 ms 3928 KB Output is correct
70 Correct 30 ms 3932 KB Output is correct
71 Correct 6 ms 2648 KB Output is correct
72 Correct 6 ms 2652 KB Output is correct
73 Correct 7 ms 2912 KB Output is correct
74 Correct 6 ms 2652 KB Output is correct
75 Correct 7 ms 2732 KB Output is correct
76 Correct 16 ms 3164 KB Output is correct
77 Correct 14 ms 3164 KB Output is correct
78 Correct 14 ms 3248 KB Output is correct
79 Correct 14 ms 3164 KB Output is correct
80 Correct 14 ms 3144 KB Output is correct
81 Correct 29 ms 3932 KB Output is correct
82 Correct 29 ms 3972 KB Output is correct
83 Correct 30 ms 3932 KB Output is correct
84 Correct 31 ms 3932 KB Output is correct
85 Correct 36 ms 3920 KB Output is correct
86 Correct 37 ms 4752 KB Output is correct
87 Correct 37 ms 4692 KB Output is correct
88 Correct 37 ms 4684 KB Output is correct
89 Correct 43 ms 4688 KB Output is correct
90 Correct 37 ms 4688 KB Output is correct
91 Correct 82 ms 12284 KB Output is correct
92 Correct 82 ms 12376 KB Output is correct
93 Correct 82 ms 12248 KB Output is correct
94 Correct 83 ms 12352 KB Output is correct
95 Correct 83 ms 12368 KB Output is correct
96 Correct 113 ms 18004 KB Output is correct
97 Correct 107 ms 18000 KB Output is correct
98 Correct 111 ms 18000 KB Output is correct
99 Correct 109 ms 17948 KB Output is correct
100 Correct 131 ms 18068 KB Output is correct
101 Correct 118 ms 17932 KB Output is correct
102 Correct 132 ms 18220 KB Output is correct
103 Correct 113 ms 18004 KB Output is correct
104 Correct 112 ms 17916 KB Output is correct
105 Correct 109 ms 17856 KB Output is correct
106 Correct 142 ms 20748 KB Output is correct
107 Correct 122 ms 20820 KB Output is correct
108 Correct 132 ms 20880 KB Output is correct
109 Correct 128 ms 20708 KB Output is correct
110 Correct 137 ms 20820 KB Output is correct
111 Correct 137 ms 20816 KB Output is correct
112 Correct 187 ms 20816 KB Output is correct
113 Correct 133 ms 20816 KB Output is correct
114 Correct 135 ms 20812 KB Output is correct
115 Correct 129 ms 20624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 6 ms 2648 KB Output is correct
15 Correct 11 ms 2908 KB Output is correct
16 Correct 18 ms 3420 KB Output is correct
17 Correct 16 ms 3396 KB Output is correct
18 Correct 16 ms 3420 KB Output is correct
19 Correct 17 ms 3420 KB Output is correct
20 Correct 17 ms 3420 KB Output is correct
21 Correct 17 ms 3384 KB Output is correct
22 Correct 17 ms 3672 KB Output is correct
23 Correct 17 ms 3420 KB Output is correct
24 Correct 17 ms 3420 KB Output is correct
25 Correct 17 ms 3576 KB Output is correct
26 Correct 1 ms 2492 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 8 ms 2784 KB Output is correct
30 Correct 14 ms 2908 KB Output is correct
31 Correct 19 ms 3676 KB Output is correct
32 Correct 19 ms 3676 KB Output is correct
33 Correct 19 ms 3928 KB Output is correct
34 Correct 19 ms 3672 KB Output is correct
35 Correct 19 ms 3676 KB Output is correct
36 Correct 20 ms 3660 KB Output is correct
37 Correct 23 ms 3932 KB Output is correct
38 Correct 19 ms 3420 KB Output is correct
39 Correct 20 ms 3676 KB Output is correct
40 Correct 20 ms 3676 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 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 2396 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 5 ms 2736 KB Output is correct
48 Correct 6 ms 2652 KB Output is correct
49 Correct 11 ms 2908 KB Output is correct
50 Correct 22 ms 3148 KB Output is correct
51 Correct 31 ms 4112 KB Output is correct
52 Correct 31 ms 3932 KB Output is correct
53 Correct 30 ms 3932 KB Output is correct
54 Correct 30 ms 3932 KB Output is correct
55 Correct 30 ms 3932 KB Output is correct
56 Correct 31 ms 4128 KB Output is correct
57 Correct 31 ms 4128 KB Output is correct
58 Correct 30 ms 4132 KB Output is correct
59 Correct 30 ms 3932 KB Output is correct
60 Correct 30 ms 3932 KB Output is correct
61 Correct 38 ms 4132 KB Output is correct
62 Correct 30 ms 4132 KB Output is correct
63 Correct 30 ms 4040 KB Output is correct
64 Correct 30 ms 4132 KB Output is correct
65 Correct 30 ms 3932 KB Output is correct
66 Correct 30 ms 4120 KB Output is correct
67 Correct 30 ms 3928 KB Output is correct
68 Correct 30 ms 4124 KB Output is correct
69 Correct 30 ms 3928 KB Output is correct
70 Correct 30 ms 3932 KB Output is correct
71 Correct 6 ms 2648 KB Output is correct
72 Correct 6 ms 2652 KB Output is correct
73 Correct 7 ms 2912 KB Output is correct
74 Correct 6 ms 2652 KB Output is correct
75 Correct 7 ms 2732 KB Output is correct
76 Correct 16 ms 3164 KB Output is correct
77 Correct 14 ms 3164 KB Output is correct
78 Correct 14 ms 3248 KB Output is correct
79 Correct 14 ms 3164 KB Output is correct
80 Correct 14 ms 3144 KB Output is correct
81 Correct 29 ms 3932 KB Output is correct
82 Correct 29 ms 3972 KB Output is correct
83 Correct 30 ms 3932 KB Output is correct
84 Correct 31 ms 3932 KB Output is correct
85 Correct 36 ms 3920 KB Output is correct
86 Correct 37 ms 4752 KB Output is correct
87 Correct 37 ms 4692 KB Output is correct
88 Correct 37 ms 4684 KB Output is correct
89 Correct 43 ms 4688 KB Output is correct
90 Correct 37 ms 4688 KB Output is correct
91 Correct 82 ms 12284 KB Output is correct
92 Correct 82 ms 12376 KB Output is correct
93 Correct 82 ms 12248 KB Output is correct
94 Correct 83 ms 12352 KB Output is correct
95 Correct 83 ms 12368 KB Output is correct
96 Correct 113 ms 18004 KB Output is correct
97 Correct 107 ms 18000 KB Output is correct
98 Correct 111 ms 18000 KB Output is correct
99 Correct 109 ms 17948 KB Output is correct
100 Correct 131 ms 18068 KB Output is correct
101 Correct 118 ms 17932 KB Output is correct
102 Correct 132 ms 18220 KB Output is correct
103 Correct 113 ms 18004 KB Output is correct
104 Correct 112 ms 17916 KB Output is correct
105 Correct 109 ms 17856 KB Output is correct
106 Correct 142 ms 20748 KB Output is correct
107 Correct 122 ms 20820 KB Output is correct
108 Correct 132 ms 20880 KB Output is correct
109 Correct 128 ms 20708 KB Output is correct
110 Correct 137 ms 20820 KB Output is correct
111 Correct 137 ms 20816 KB Output is correct
112 Correct 187 ms 20816 KB Output is correct
113 Correct 133 ms 20816 KB Output is correct
114 Correct 135 ms 20812 KB Output is correct
115 Correct 129 ms 20624 KB Output is correct
116 Incorrect 1 ms 2396 KB Output isn't correct
117 Halted 0 ms 0 KB -