답안 #959263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959263 2024-04-07T18:40:06 Z Dan4Life Diversity (CEOI21_diversity) C++17
64 / 100
102 ms 11460 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)3e5+10;
int n, q, a[mxN], d[mxN], pr[mxN];
vector<int> v;
 
int f(){
	d[0] = a[0]*(a[0]+1)/2;
	int tot = d[0], SZ = a[0]; 
	pr[0]=(d[0]-a[0]*(a[0]-1)/2)/a[0];
	for(int i = 1; i < n; i++){
		d[i] = pr[i-1]+a[i-1]-1+SZ+1;
		pr[i] = d[i]; d[i] *= a[i];
		d[i] += a[i]*(a[i]-1)/2;
		tot+=d[i]; SZ+=a[i];
	}
	return tot;
}
 
int32_t main() {
	cin >> n >> q;
	int ans = mxN*mxN*mxN;
	for(int i = 0; i < n; i++) cin >> a[i];
	cin >> q >> q; sort(a,a+n);
	for(int i = 0; i < n; i++){
	    int j = i;
	    while(i<n-1 and a[i]==a[i+1]) i++;
	    v.pb(i-j+1);
	} 
	n = sz(v); sort(all(v));
 
	int l = 0, r = n-1;
	for(int i = 0; i < n; i++){
		if(i%2==0) a[l++]=v[i];
		else a[r--] = v[i];
	}
	cout << f() << "\n";
}

Compilation message

diversity.cpp: In function 'int32_t main()':
diversity.cpp:26:6: warning: unused variable 'ans' [-Wunused-variable]
   26 |  int ans = mxN*mxN*mxN;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4536 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 3 ms 4444 KB Output is correct
4 Correct 13 ms 4700 KB Output is correct
5 Correct 25 ms 4700 KB Output is correct
6 Correct 46 ms 5852 KB Output is correct
7 Correct 38 ms 5724 KB Output is correct
8 Correct 39 ms 5712 KB Output is correct
9 Correct 40 ms 5660 KB Output is correct
10 Correct 39 ms 5716 KB Output is correct
11 Correct 39 ms 5860 KB Output is correct
12 Correct 40 ms 5712 KB Output is correct
13 Correct 39 ms 5716 KB Output is correct
14 Correct 39 ms 5716 KB Output is correct
15 Correct 39 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 3 ms 4444 KB Output is correct
4 Correct 13 ms 4700 KB Output is correct
5 Correct 25 ms 4700 KB Output is correct
6 Correct 46 ms 5852 KB Output is correct
7 Correct 38 ms 5724 KB Output is correct
8 Correct 39 ms 5712 KB Output is correct
9 Correct 40 ms 5660 KB Output is correct
10 Correct 39 ms 5716 KB Output is correct
11 Correct 39 ms 5860 KB Output is correct
12 Correct 40 ms 5712 KB Output is correct
13 Correct 39 ms 5716 KB Output is correct
14 Correct 39 ms 5716 KB Output is correct
15 Correct 39 ms 5712 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 2 ms 4552 KB Output is correct
19 Correct 15 ms 4700 KB Output is correct
20 Correct 32 ms 4948 KB Output is correct
21 Correct 45 ms 5924 KB Output is correct
22 Correct 43 ms 5972 KB Output is correct
23 Correct 44 ms 5980 KB Output is correct
24 Correct 44 ms 5972 KB Output is correct
25 Correct 48 ms 5800 KB Output is correct
26 Correct 43 ms 5920 KB Output is correct
27 Correct 44 ms 5968 KB Output is correct
28 Correct 42 ms 5712 KB Output is correct
29 Correct 45 ms 5968 KB Output is correct
30 Correct 44 ms 5972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 3 ms 4444 KB Output is correct
4 Correct 13 ms 4700 KB Output is correct
5 Correct 25 ms 4700 KB Output is correct
6 Correct 46 ms 5852 KB Output is correct
7 Correct 38 ms 5724 KB Output is correct
8 Correct 39 ms 5712 KB Output is correct
9 Correct 40 ms 5660 KB Output is correct
10 Correct 39 ms 5716 KB Output is correct
11 Correct 39 ms 5860 KB Output is correct
12 Correct 40 ms 5712 KB Output is correct
13 Correct 39 ms 5716 KB Output is correct
14 Correct 39 ms 5716 KB Output is correct
15 Correct 39 ms 5712 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 2 ms 4552 KB Output is correct
19 Correct 15 ms 4700 KB Output is correct
20 Correct 32 ms 4948 KB Output is correct
21 Correct 45 ms 5924 KB Output is correct
22 Correct 43 ms 5972 KB Output is correct
23 Correct 44 ms 5980 KB Output is correct
24 Correct 44 ms 5972 KB Output is correct
25 Correct 48 ms 5800 KB Output is correct
26 Correct 43 ms 5920 KB Output is correct
27 Correct 44 ms 5968 KB Output is correct
28 Correct 42 ms 5712 KB Output is correct
29 Correct 45 ms 5968 KB Output is correct
30 Correct 44 ms 5972 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4440 KB Output is correct
34 Correct 2 ms 4692 KB Output is correct
35 Correct 3 ms 4552 KB Output is correct
36 Correct 5 ms 4440 KB Output is correct
37 Correct 11 ms 4728 KB Output is correct
38 Correct 10 ms 4700 KB Output is correct
39 Correct 19 ms 4700 KB Output is correct
40 Correct 37 ms 5204 KB Output is correct
41 Correct 55 ms 6228 KB Output is correct
42 Correct 55 ms 6380 KB Output is correct
43 Correct 55 ms 6484 KB Output is correct
44 Correct 55 ms 6296 KB Output is correct
45 Correct 55 ms 6232 KB Output is correct
46 Correct 54 ms 6228 KB Output is correct
47 Correct 54 ms 6228 KB Output is correct
48 Correct 61 ms 6220 KB Output is correct
49 Correct 65 ms 6216 KB Output is correct
50 Correct 54 ms 6224 KB Output is correct
51 Correct 55 ms 6312 KB Output is correct
52 Correct 56 ms 6228 KB Output is correct
53 Correct 59 ms 6160 KB Output is correct
54 Correct 55 ms 6232 KB Output is correct
55 Correct 58 ms 6176 KB Output is correct
56 Correct 55 ms 6288 KB Output is correct
57 Correct 54 ms 6224 KB Output is correct
58 Correct 62 ms 6224 KB Output is correct
59 Correct 58 ms 6380 KB Output is correct
60 Correct 56 ms 6360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4536 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 3 ms 4444 KB Output is correct
14 Correct 13 ms 4700 KB Output is correct
15 Correct 25 ms 4700 KB Output is correct
16 Correct 46 ms 5852 KB Output is correct
17 Correct 38 ms 5724 KB Output is correct
18 Correct 39 ms 5712 KB Output is correct
19 Correct 40 ms 5660 KB Output is correct
20 Correct 39 ms 5716 KB Output is correct
21 Correct 39 ms 5860 KB Output is correct
22 Correct 40 ms 5712 KB Output is correct
23 Correct 39 ms 5716 KB Output is correct
24 Correct 39 ms 5716 KB Output is correct
25 Correct 39 ms 5712 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 2 ms 4552 KB Output is correct
29 Correct 15 ms 4700 KB Output is correct
30 Correct 32 ms 4948 KB Output is correct
31 Correct 45 ms 5924 KB Output is correct
32 Correct 43 ms 5972 KB Output is correct
33 Correct 44 ms 5980 KB Output is correct
34 Correct 44 ms 5972 KB Output is correct
35 Correct 48 ms 5800 KB Output is correct
36 Correct 43 ms 5920 KB Output is correct
37 Correct 44 ms 5968 KB Output is correct
38 Correct 42 ms 5712 KB Output is correct
39 Correct 45 ms 5968 KB Output is correct
40 Correct 44 ms 5972 KB Output is correct
41 Correct 1 ms 4440 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 2 ms 4692 KB Output is correct
45 Correct 3 ms 4552 KB Output is correct
46 Correct 5 ms 4440 KB Output is correct
47 Correct 11 ms 4728 KB Output is correct
48 Correct 10 ms 4700 KB Output is correct
49 Correct 19 ms 4700 KB Output is correct
50 Correct 37 ms 5204 KB Output is correct
51 Correct 55 ms 6228 KB Output is correct
52 Correct 55 ms 6380 KB Output is correct
53 Correct 55 ms 6484 KB Output is correct
54 Correct 55 ms 6296 KB Output is correct
55 Correct 55 ms 6232 KB Output is correct
56 Correct 54 ms 6228 KB Output is correct
57 Correct 54 ms 6228 KB Output is correct
58 Correct 61 ms 6220 KB Output is correct
59 Correct 65 ms 6216 KB Output is correct
60 Correct 54 ms 6224 KB Output is correct
61 Correct 55 ms 6312 KB Output is correct
62 Correct 56 ms 6228 KB Output is correct
63 Correct 59 ms 6160 KB Output is correct
64 Correct 55 ms 6232 KB Output is correct
65 Correct 58 ms 6176 KB Output is correct
66 Correct 55 ms 6288 KB Output is correct
67 Correct 54 ms 6224 KB Output is correct
68 Correct 62 ms 6224 KB Output is correct
69 Correct 58 ms 6380 KB Output is correct
70 Correct 56 ms 6360 KB Output is correct
71 Correct 12 ms 4700 KB Output is correct
72 Correct 11 ms 4952 KB Output is correct
73 Correct 11 ms 4948 KB Output is correct
74 Correct 11 ms 4700 KB Output is correct
75 Correct 14 ms 4956 KB Output is correct
76 Correct 23 ms 5012 KB Output is correct
77 Correct 22 ms 4996 KB Output is correct
78 Correct 22 ms 4944 KB Output is correct
79 Correct 23 ms 4956 KB Output is correct
80 Correct 22 ms 4948 KB Output is correct
81 Correct 45 ms 5744 KB Output is correct
82 Correct 45 ms 5748 KB Output is correct
83 Correct 45 ms 5712 KB Output is correct
84 Correct 46 ms 5552 KB Output is correct
85 Correct 46 ms 5712 KB Output is correct
86 Correct 49 ms 5960 KB Output is correct
87 Correct 48 ms 5960 KB Output is correct
88 Correct 48 ms 6028 KB Output is correct
89 Correct 49 ms 5836 KB Output is correct
90 Correct 49 ms 5836 KB Output is correct
91 Correct 81 ms 9856 KB Output is correct
92 Correct 81 ms 9996 KB Output is correct
93 Correct 93 ms 9928 KB Output is correct
94 Correct 80 ms 9880 KB Output is correct
95 Correct 82 ms 9880 KB Output is correct
96 Correct 87 ms 10808 KB Output is correct
97 Correct 86 ms 10812 KB Output is correct
98 Correct 90 ms 11108 KB Output is correct
99 Correct 86 ms 10844 KB Output is correct
100 Correct 87 ms 10948 KB Output is correct
101 Correct 87 ms 10948 KB Output is correct
102 Correct 87 ms 10948 KB Output is correct
103 Correct 89 ms 10948 KB Output is correct
104 Correct 87 ms 10836 KB Output is correct
105 Correct 86 ms 10948 KB Output is correct
106 Correct 87 ms 11460 KB Output is correct
107 Correct 88 ms 11392 KB Output is correct
108 Correct 87 ms 11276 KB Output is correct
109 Correct 87 ms 11400 KB Output is correct
110 Correct 87 ms 11456 KB Output is correct
111 Correct 102 ms 11356 KB Output is correct
112 Correct 91 ms 11460 KB Output is correct
113 Correct 88 ms 11460 KB Output is correct
114 Correct 88 ms 11460 KB Output is correct
115 Correct 88 ms 11408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4536 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4440 KB Output is correct
13 Correct 3 ms 4444 KB Output is correct
14 Correct 13 ms 4700 KB Output is correct
15 Correct 25 ms 4700 KB Output is correct
16 Correct 46 ms 5852 KB Output is correct
17 Correct 38 ms 5724 KB Output is correct
18 Correct 39 ms 5712 KB Output is correct
19 Correct 40 ms 5660 KB Output is correct
20 Correct 39 ms 5716 KB Output is correct
21 Correct 39 ms 5860 KB Output is correct
22 Correct 40 ms 5712 KB Output is correct
23 Correct 39 ms 5716 KB Output is correct
24 Correct 39 ms 5716 KB Output is correct
25 Correct 39 ms 5712 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 2 ms 4552 KB Output is correct
29 Correct 15 ms 4700 KB Output is correct
30 Correct 32 ms 4948 KB Output is correct
31 Correct 45 ms 5924 KB Output is correct
32 Correct 43 ms 5972 KB Output is correct
33 Correct 44 ms 5980 KB Output is correct
34 Correct 44 ms 5972 KB Output is correct
35 Correct 48 ms 5800 KB Output is correct
36 Correct 43 ms 5920 KB Output is correct
37 Correct 44 ms 5968 KB Output is correct
38 Correct 42 ms 5712 KB Output is correct
39 Correct 45 ms 5968 KB Output is correct
40 Correct 44 ms 5972 KB Output is correct
41 Correct 1 ms 4440 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 2 ms 4692 KB Output is correct
45 Correct 3 ms 4552 KB Output is correct
46 Correct 5 ms 4440 KB Output is correct
47 Correct 11 ms 4728 KB Output is correct
48 Correct 10 ms 4700 KB Output is correct
49 Correct 19 ms 4700 KB Output is correct
50 Correct 37 ms 5204 KB Output is correct
51 Correct 55 ms 6228 KB Output is correct
52 Correct 55 ms 6380 KB Output is correct
53 Correct 55 ms 6484 KB Output is correct
54 Correct 55 ms 6296 KB Output is correct
55 Correct 55 ms 6232 KB Output is correct
56 Correct 54 ms 6228 KB Output is correct
57 Correct 54 ms 6228 KB Output is correct
58 Correct 61 ms 6220 KB Output is correct
59 Correct 65 ms 6216 KB Output is correct
60 Correct 54 ms 6224 KB Output is correct
61 Correct 55 ms 6312 KB Output is correct
62 Correct 56 ms 6228 KB Output is correct
63 Correct 59 ms 6160 KB Output is correct
64 Correct 55 ms 6232 KB Output is correct
65 Correct 58 ms 6176 KB Output is correct
66 Correct 55 ms 6288 KB Output is correct
67 Correct 54 ms 6224 KB Output is correct
68 Correct 62 ms 6224 KB Output is correct
69 Correct 58 ms 6380 KB Output is correct
70 Correct 56 ms 6360 KB Output is correct
71 Correct 12 ms 4700 KB Output is correct
72 Correct 11 ms 4952 KB Output is correct
73 Correct 11 ms 4948 KB Output is correct
74 Correct 11 ms 4700 KB Output is correct
75 Correct 14 ms 4956 KB Output is correct
76 Correct 23 ms 5012 KB Output is correct
77 Correct 22 ms 4996 KB Output is correct
78 Correct 22 ms 4944 KB Output is correct
79 Correct 23 ms 4956 KB Output is correct
80 Correct 22 ms 4948 KB Output is correct
81 Correct 45 ms 5744 KB Output is correct
82 Correct 45 ms 5748 KB Output is correct
83 Correct 45 ms 5712 KB Output is correct
84 Correct 46 ms 5552 KB Output is correct
85 Correct 46 ms 5712 KB Output is correct
86 Correct 49 ms 5960 KB Output is correct
87 Correct 48 ms 5960 KB Output is correct
88 Correct 48 ms 6028 KB Output is correct
89 Correct 49 ms 5836 KB Output is correct
90 Correct 49 ms 5836 KB Output is correct
91 Correct 81 ms 9856 KB Output is correct
92 Correct 81 ms 9996 KB Output is correct
93 Correct 93 ms 9928 KB Output is correct
94 Correct 80 ms 9880 KB Output is correct
95 Correct 82 ms 9880 KB Output is correct
96 Correct 87 ms 10808 KB Output is correct
97 Correct 86 ms 10812 KB Output is correct
98 Correct 90 ms 11108 KB Output is correct
99 Correct 86 ms 10844 KB Output is correct
100 Correct 87 ms 10948 KB Output is correct
101 Correct 87 ms 10948 KB Output is correct
102 Correct 87 ms 10948 KB Output is correct
103 Correct 89 ms 10948 KB Output is correct
104 Correct 87 ms 10836 KB Output is correct
105 Correct 86 ms 10948 KB Output is correct
106 Correct 87 ms 11460 KB Output is correct
107 Correct 88 ms 11392 KB Output is correct
108 Correct 87 ms 11276 KB Output is correct
109 Correct 87 ms 11400 KB Output is correct
110 Correct 87 ms 11456 KB Output is correct
111 Correct 102 ms 11356 KB Output is correct
112 Correct 91 ms 11460 KB Output is correct
113 Correct 88 ms 11460 KB Output is correct
114 Correct 88 ms 11460 KB Output is correct
115 Correct 88 ms 11408 KB Output is correct
116 Incorrect 3 ms 4440 KB Output isn't correct
117 Halted 0 ms 0 KB -