# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
713235 | 2023-03-21T10:58:26 Z | Pacybwoah | Diversity (CEOI21_diversity) | C++14 | 99 ms | 13276 KB |
#include<iostream> #include<vector> #include<algorithm> #define ll long long using namespace std; int main(){ ll n,q; cin>>n>>q; if(q!=1) return 0; int a,b; vector<ll> vec(n); for(int i=0;i<n;i++) cin>>vec[i]; cin>>a>>b; vector<ll> cnt(300001); for(int i=0;i<n;i++) cnt[vec[i]]++; vector<ll> p; for(int i=0;i<=300000;i++){ if(cnt[i]>0) p.push_back(cnt[i]); } sort(p.begin(),p.end()); vector<ll> f; for(int i=0;i<p.size();i+=2){ f.push_back(p[i]); } for(int i=(p.size()%2==0?p.size()-1:p.size()-2);i>=0;i-=2) f.push_back(p[i]); ll sum=0,len=f.size(); vector<ll> pre1(len),pre2(len); for(int i=1;i<len;i++){ pre1[i]=pre1[i-1]+f[i]*i; pre2[i]=pre2[i-1]+f[i]; } for(ll i=0;i<len;i++){ sum+=f[i]*(f[i]+1)/2; sum+=f[i]*(pre1[len-1]-pre1[i]-(i-1)*(pre2[len-1]-pre2[i])); } cout<<sum<<"\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 2 ms | 2644 KB | Output is correct |
4 | Correct | 2 ms | 2644 KB | Output is correct |
5 | Correct | 2 ms | 2644 KB | Output is correct |
6 | Correct | 2 ms | 2644 KB | Output is correct |
7 | Correct | 2 ms | 2604 KB | Output is correct |
8 | Correct | 2 ms | 2644 KB | Output is correct |
9 | Correct | 2 ms | 2584 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2600 KB | Output is correct |
3 | Correct | 3 ms | 2644 KB | Output is correct |
4 | Correct | 14 ms | 3528 KB | Output is correct |
5 | Correct | 27 ms | 4308 KB | Output is correct |
6 | Correct | 55 ms | 5064 KB | Output is correct |
7 | Correct | 43 ms | 5076 KB | Output is correct |
8 | Correct | 42 ms | 5080 KB | Output is correct |
9 | Correct | 51 ms | 5032 KB | Output is correct |
10 | Correct | 44 ms | 5068 KB | Output is correct |
11 | Correct | 43 ms | 5080 KB | Output is correct |
12 | Correct | 43 ms | 5080 KB | Output is correct |
13 | Correct | 42 ms | 5076 KB | Output is correct |
14 | Correct | 43 ms | 5072 KB | Output is correct |
15 | Correct | 45 ms | 5064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2600 KB | Output is correct |
3 | Correct | 3 ms | 2644 KB | Output is correct |
4 | Correct | 14 ms | 3528 KB | Output is correct |
5 | Correct | 27 ms | 4308 KB | Output is correct |
6 | Correct | 55 ms | 5064 KB | Output is correct |
7 | Correct | 43 ms | 5076 KB | Output is correct |
8 | Correct | 42 ms | 5080 KB | Output is correct |
9 | Correct | 51 ms | 5032 KB | Output is correct |
10 | Correct | 44 ms | 5068 KB | Output is correct |
11 | Correct | 43 ms | 5080 KB | Output is correct |
12 | Correct | 43 ms | 5080 KB | Output is correct |
13 | Correct | 42 ms | 5076 KB | Output is correct |
14 | Correct | 43 ms | 5072 KB | Output is correct |
15 | Correct | 45 ms | 5064 KB | Output is correct |
16 | Correct | 2 ms | 2644 KB | Output is correct |
17 | Correct | 2 ms | 2644 KB | Output is correct |
18 | Correct | 4 ms | 2740 KB | Output is correct |
19 | Correct | 18 ms | 3456 KB | Output is correct |
20 | Correct | 34 ms | 4300 KB | Output is correct |
21 | Correct | 62 ms | 5068 KB | Output is correct |
22 | Correct | 46 ms | 5084 KB | Output is correct |
23 | Correct | 47 ms | 5008 KB | Output is correct |
24 | Correct | 47 ms | 5080 KB | Output is correct |
25 | Correct | 49 ms | 5072 KB | Output is correct |
26 | Correct | 53 ms | 5084 KB | Output is correct |
27 | Correct | 53 ms | 5080 KB | Output is correct |
28 | Correct | 45 ms | 5068 KB | Output is correct |
29 | Correct | 46 ms | 5080 KB | Output is correct |
30 | Correct | 47 ms | 5064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2600 KB | Output is correct |
3 | Correct | 3 ms | 2644 KB | Output is correct |
4 | Correct | 14 ms | 3528 KB | Output is correct |
5 | Correct | 27 ms | 4308 KB | Output is correct |
6 | Correct | 55 ms | 5064 KB | Output is correct |
7 | Correct | 43 ms | 5076 KB | Output is correct |
8 | Correct | 42 ms | 5080 KB | Output is correct |
9 | Correct | 51 ms | 5032 KB | Output is correct |
10 | Correct | 44 ms | 5068 KB | Output is correct |
11 | Correct | 43 ms | 5080 KB | Output is correct |
12 | Correct | 43 ms | 5080 KB | Output is correct |
13 | Correct | 42 ms | 5076 KB | Output is correct |
14 | Correct | 43 ms | 5072 KB | Output is correct |
15 | Correct | 45 ms | 5064 KB | Output is correct |
16 | Correct | 2 ms | 2644 KB | Output is correct |
17 | Correct | 2 ms | 2644 KB | Output is correct |
18 | Correct | 4 ms | 2740 KB | Output is correct |
19 | Correct | 18 ms | 3456 KB | Output is correct |
20 | Correct | 34 ms | 4300 KB | Output is correct |
21 | Correct | 62 ms | 5068 KB | Output is correct |
22 | Correct | 46 ms | 5084 KB | Output is correct |
23 | Correct | 47 ms | 5008 KB | Output is correct |
24 | Correct | 47 ms | 5080 KB | Output is correct |
25 | Correct | 49 ms | 5072 KB | Output is correct |
26 | Correct | 53 ms | 5084 KB | Output is correct |
27 | Correct | 53 ms | 5080 KB | Output is correct |
28 | Correct | 45 ms | 5068 KB | Output is correct |
29 | Correct | 46 ms | 5080 KB | Output is correct |
30 | Correct | 47 ms | 5064 KB | Output is correct |
31 | Correct | 2 ms | 2644 KB | Output is correct |
32 | Correct | 2 ms | 2600 KB | Output is correct |
33 | Correct | 2 ms | 2644 KB | Output is correct |
34 | Correct | 3 ms | 2644 KB | Output is correct |
35 | Correct | 4 ms | 2772 KB | Output is correct |
36 | Correct | 4 ms | 2772 KB | Output is correct |
37 | Correct | 11 ms | 3136 KB | Output is correct |
38 | Correct | 11 ms | 3136 KB | Output is correct |
39 | Correct | 21 ms | 3532 KB | Output is correct |
40 | Correct | 41 ms | 4296 KB | Output is correct |
41 | Correct | 59 ms | 5084 KB | Output is correct |
42 | Correct | 67 ms | 5068 KB | Output is correct |
43 | Correct | 61 ms | 5068 KB | Output is correct |
44 | Correct | 58 ms | 5064 KB | Output is correct |
45 | Correct | 58 ms | 5080 KB | Output is correct |
46 | Correct | 58 ms | 5064 KB | Output is correct |
47 | Correct | 56 ms | 5084 KB | Output is correct |
48 | Correct | 57 ms | 5060 KB | Output is correct |
49 | Correct | 58 ms | 5072 KB | Output is correct |
50 | Correct | 61 ms | 5064 KB | Output is correct |
51 | Correct | 57 ms | 5076 KB | Output is correct |
52 | Correct | 57 ms | 5064 KB | Output is correct |
53 | Correct | 58 ms | 5084 KB | Output is correct |
54 | Correct | 63 ms | 5072 KB | Output is correct |
55 | Correct | 58 ms | 5080 KB | Output is correct |
56 | Correct | 60 ms | 5068 KB | Output is correct |
57 | Correct | 57 ms | 5080 KB | Output is correct |
58 | Correct | 61 ms | 5084 KB | Output is correct |
59 | Correct | 59 ms | 5068 KB | Output is correct |
60 | Correct | 57 ms | 5064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 2 ms | 2644 KB | Output is correct |
4 | Correct | 2 ms | 2644 KB | Output is correct |
5 | Correct | 2 ms | 2644 KB | Output is correct |
6 | Correct | 2 ms | 2644 KB | Output is correct |
7 | Correct | 2 ms | 2604 KB | Output is correct |
8 | Correct | 2 ms | 2644 KB | Output is correct |
9 | Correct | 2 ms | 2584 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
11 | Correct | 2 ms | 2644 KB | Output is correct |
12 | Correct | 2 ms | 2600 KB | Output is correct |
13 | Correct | 3 ms | 2644 KB | Output is correct |
14 | Correct | 14 ms | 3528 KB | Output is correct |
15 | Correct | 27 ms | 4308 KB | Output is correct |
16 | Correct | 55 ms | 5064 KB | Output is correct |
17 | Correct | 43 ms | 5076 KB | Output is correct |
18 | Correct | 42 ms | 5080 KB | Output is correct |
19 | Correct | 51 ms | 5032 KB | Output is correct |
20 | Correct | 44 ms | 5068 KB | Output is correct |
21 | Correct | 43 ms | 5080 KB | Output is correct |
22 | Correct | 43 ms | 5080 KB | Output is correct |
23 | Correct | 42 ms | 5076 KB | Output is correct |
24 | Correct | 43 ms | 5072 KB | Output is correct |
25 | Correct | 45 ms | 5064 KB | Output is correct |
26 | Correct | 2 ms | 2644 KB | Output is correct |
27 | Correct | 2 ms | 2644 KB | Output is correct |
28 | Correct | 4 ms | 2740 KB | Output is correct |
29 | Correct | 18 ms | 3456 KB | Output is correct |
30 | Correct | 34 ms | 4300 KB | Output is correct |
31 | Correct | 62 ms | 5068 KB | Output is correct |
32 | Correct | 46 ms | 5084 KB | Output is correct |
33 | Correct | 47 ms | 5008 KB | Output is correct |
34 | Correct | 47 ms | 5080 KB | Output is correct |
35 | Correct | 49 ms | 5072 KB | Output is correct |
36 | Correct | 53 ms | 5084 KB | Output is correct |
37 | Correct | 53 ms | 5080 KB | Output is correct |
38 | Correct | 45 ms | 5068 KB | Output is correct |
39 | Correct | 46 ms | 5080 KB | Output is correct |
40 | Correct | 47 ms | 5064 KB | Output is correct |
41 | Correct | 2 ms | 2644 KB | Output is correct |
42 | Correct | 2 ms | 2600 KB | Output is correct |
43 | Correct | 2 ms | 2644 KB | Output is correct |
44 | Correct | 3 ms | 2644 KB | Output is correct |
45 | Correct | 4 ms | 2772 KB | Output is correct |
46 | Correct | 4 ms | 2772 KB | Output is correct |
47 | Correct | 11 ms | 3136 KB | Output is correct |
48 | Correct | 11 ms | 3136 KB | Output is correct |
49 | Correct | 21 ms | 3532 KB | Output is correct |
50 | Correct | 41 ms | 4296 KB | Output is correct |
51 | Correct | 59 ms | 5084 KB | Output is correct |
52 | Correct | 67 ms | 5068 KB | Output is correct |
53 | Correct | 61 ms | 5068 KB | Output is correct |
54 | Correct | 58 ms | 5064 KB | Output is correct |
55 | Correct | 58 ms | 5080 KB | Output is correct |
56 | Correct | 58 ms | 5064 KB | Output is correct |
57 | Correct | 56 ms | 5084 KB | Output is correct |
58 | Correct | 57 ms | 5060 KB | Output is correct |
59 | Correct | 58 ms | 5072 KB | Output is correct |
60 | Correct | 61 ms | 5064 KB | Output is correct |
61 | Correct | 57 ms | 5076 KB | Output is correct |
62 | Correct | 57 ms | 5064 KB | Output is correct |
63 | Correct | 58 ms | 5084 KB | Output is correct |
64 | Correct | 63 ms | 5072 KB | Output is correct |
65 | Correct | 58 ms | 5080 KB | Output is correct |
66 | Correct | 60 ms | 5068 KB | Output is correct |
67 | Correct | 57 ms | 5080 KB | Output is correct |
68 | Correct | 61 ms | 5084 KB | Output is correct |
69 | Correct | 59 ms | 5068 KB | Output is correct |
70 | Correct | 57 ms | 5064 KB | Output is correct |
71 | Correct | 12 ms | 3156 KB | Output is correct |
72 | Correct | 13 ms | 3132 KB | Output is correct |
73 | Correct | 13 ms | 3156 KB | Output is correct |
74 | Correct | 18 ms | 3176 KB | Output is correct |
75 | Correct | 14 ms | 3256 KB | Output is correct |
76 | Correct | 23 ms | 3636 KB | Output is correct |
77 | Correct | 27 ms | 3652 KB | Output is correct |
78 | Correct | 24 ms | 3640 KB | Output is correct |
79 | Correct | 24 ms | 3660 KB | Output is correct |
80 | Correct | 23 ms | 3640 KB | Output is correct |
81 | Correct | 46 ms | 4588 KB | Output is correct |
82 | Correct | 45 ms | 4556 KB | Output is correct |
83 | Correct | 46 ms | 4552 KB | Output is correct |
84 | Correct | 46 ms | 4556 KB | Output is correct |
85 | Correct | 45 ms | 4556 KB | Output is correct |
86 | Correct | 48 ms | 5064 KB | Output is correct |
87 | Correct | 51 ms | 5064 KB | Output is correct |
88 | Correct | 48 ms | 5072 KB | Output is correct |
89 | Correct | 49 ms | 5076 KB | Output is correct |
90 | Correct | 48 ms | 5068 KB | Output is correct |
91 | Correct | 79 ms | 8260 KB | Output is correct |
92 | Correct | 80 ms | 8260 KB | Output is correct |
93 | Correct | 81 ms | 8272 KB | Output is correct |
94 | Correct | 82 ms | 8260 KB | Output is correct |
95 | Correct | 81 ms | 8388 KB | Output is correct |
96 | Correct | 88 ms | 11456 KB | Output is correct |
97 | Correct | 96 ms | 11584 KB | Output is correct |
98 | Correct | 87 ms | 11524 KB | Output is correct |
99 | Correct | 90 ms | 11716 KB | Output is correct |
100 | Correct | 90 ms | 11616 KB | Output is correct |
101 | Correct | 90 ms | 11592 KB | Output is correct |
102 | Correct | 89 ms | 11632 KB | Output is correct |
103 | Correct | 90 ms | 11560 KB | Output is correct |
104 | Correct | 90 ms | 11608 KB | Output is correct |
105 | Correct | 91 ms | 11584 KB | Output is correct |
106 | Correct | 94 ms | 13276 KB | Output is correct |
107 | Correct | 92 ms | 13176 KB | Output is correct |
108 | Correct | 96 ms | 13144 KB | Output is correct |
109 | Correct | 91 ms | 13120 KB | Output is correct |
110 | Correct | 93 ms | 13116 KB | Output is correct |
111 | Correct | 93 ms | 13172 KB | Output is correct |
112 | Correct | 95 ms | 13120 KB | Output is correct |
113 | Correct | 99 ms | 13208 KB | Output is correct |
114 | Correct | 96 ms | 13128 KB | Output is correct |
115 | Correct | 92 ms | 13120 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 2 ms | 2644 KB | Output is correct |
4 | Correct | 2 ms | 2644 KB | Output is correct |
5 | Correct | 2 ms | 2644 KB | Output is correct |
6 | Correct | 2 ms | 2644 KB | Output is correct |
7 | Correct | 2 ms | 2604 KB | Output is correct |
8 | Correct | 2 ms | 2644 KB | Output is correct |
9 | Correct | 2 ms | 2584 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
11 | Correct | 2 ms | 2644 KB | Output is correct |
12 | Correct | 2 ms | 2600 KB | Output is correct |
13 | Correct | 3 ms | 2644 KB | Output is correct |
14 | Correct | 14 ms | 3528 KB | Output is correct |
15 | Correct | 27 ms | 4308 KB | Output is correct |
16 | Correct | 55 ms | 5064 KB | Output is correct |
17 | Correct | 43 ms | 5076 KB | Output is correct |
18 | Correct | 42 ms | 5080 KB | Output is correct |
19 | Correct | 51 ms | 5032 KB | Output is correct |
20 | Correct | 44 ms | 5068 KB | Output is correct |
21 | Correct | 43 ms | 5080 KB | Output is correct |
22 | Correct | 43 ms | 5080 KB | Output is correct |
23 | Correct | 42 ms | 5076 KB | Output is correct |
24 | Correct | 43 ms | 5072 KB | Output is correct |
25 | Correct | 45 ms | 5064 KB | Output is correct |
26 | Correct | 2 ms | 2644 KB | Output is correct |
27 | Correct | 2 ms | 2644 KB | Output is correct |
28 | Correct | 4 ms | 2740 KB | Output is correct |
29 | Correct | 18 ms | 3456 KB | Output is correct |
30 | Correct | 34 ms | 4300 KB | Output is correct |
31 | Correct | 62 ms | 5068 KB | Output is correct |
32 | Correct | 46 ms | 5084 KB | Output is correct |
33 | Correct | 47 ms | 5008 KB | Output is correct |
34 | Correct | 47 ms | 5080 KB | Output is correct |
35 | Correct | 49 ms | 5072 KB | Output is correct |
36 | Correct | 53 ms | 5084 KB | Output is correct |
37 | Correct | 53 ms | 5080 KB | Output is correct |
38 | Correct | 45 ms | 5068 KB | Output is correct |
39 | Correct | 46 ms | 5080 KB | Output is correct |
40 | Correct | 47 ms | 5064 KB | Output is correct |
41 | Correct | 2 ms | 2644 KB | Output is correct |
42 | Correct | 2 ms | 2600 KB | Output is correct |
43 | Correct | 2 ms | 2644 KB | Output is correct |
44 | Correct | 3 ms | 2644 KB | Output is correct |
45 | Correct | 4 ms | 2772 KB | Output is correct |
46 | Correct | 4 ms | 2772 KB | Output is correct |
47 | Correct | 11 ms | 3136 KB | Output is correct |
48 | Correct | 11 ms | 3136 KB | Output is correct |
49 | Correct | 21 ms | 3532 KB | Output is correct |
50 | Correct | 41 ms | 4296 KB | Output is correct |
51 | Correct | 59 ms | 5084 KB | Output is correct |
52 | Correct | 67 ms | 5068 KB | Output is correct |
53 | Correct | 61 ms | 5068 KB | Output is correct |
54 | Correct | 58 ms | 5064 KB | Output is correct |
55 | Correct | 58 ms | 5080 KB | Output is correct |
56 | Correct | 58 ms | 5064 KB | Output is correct |
57 | Correct | 56 ms | 5084 KB | Output is correct |
58 | Correct | 57 ms | 5060 KB | Output is correct |
59 | Correct | 58 ms | 5072 KB | Output is correct |
60 | Correct | 61 ms | 5064 KB | Output is correct |
61 | Correct | 57 ms | 5076 KB | Output is correct |
62 | Correct | 57 ms | 5064 KB | Output is correct |
63 | Correct | 58 ms | 5084 KB | Output is correct |
64 | Correct | 63 ms | 5072 KB | Output is correct |
65 | Correct | 58 ms | 5080 KB | Output is correct |
66 | Correct | 60 ms | 5068 KB | Output is correct |
67 | Correct | 57 ms | 5080 KB | Output is correct |
68 | Correct | 61 ms | 5084 KB | Output is correct |
69 | Correct | 59 ms | 5068 KB | Output is correct |
70 | Correct | 57 ms | 5064 KB | Output is correct |
71 | Correct | 12 ms | 3156 KB | Output is correct |
72 | Correct | 13 ms | 3132 KB | Output is correct |
73 | Correct | 13 ms | 3156 KB | Output is correct |
74 | Correct | 18 ms | 3176 KB | Output is correct |
75 | Correct | 14 ms | 3256 KB | Output is correct |
76 | Correct | 23 ms | 3636 KB | Output is correct |
77 | Correct | 27 ms | 3652 KB | Output is correct |
78 | Correct | 24 ms | 3640 KB | Output is correct |
79 | Correct | 24 ms | 3660 KB | Output is correct |
80 | Correct | 23 ms | 3640 KB | Output is correct |
81 | Correct | 46 ms | 4588 KB | Output is correct |
82 | Correct | 45 ms | 4556 KB | Output is correct |
83 | Correct | 46 ms | 4552 KB | Output is correct |
84 | Correct | 46 ms | 4556 KB | Output is correct |
85 | Correct | 45 ms | 4556 KB | Output is correct |
86 | Correct | 48 ms | 5064 KB | Output is correct |
87 | Correct | 51 ms | 5064 KB | Output is correct |
88 | Correct | 48 ms | 5072 KB | Output is correct |
89 | Correct | 49 ms | 5076 KB | Output is correct |
90 | Correct | 48 ms | 5068 KB | Output is correct |
91 | Correct | 79 ms | 8260 KB | Output is correct |
92 | Correct | 80 ms | 8260 KB | Output is correct |
93 | Correct | 81 ms | 8272 KB | Output is correct |
94 | Correct | 82 ms | 8260 KB | Output is correct |
95 | Correct | 81 ms | 8388 KB | Output is correct |
96 | Correct | 88 ms | 11456 KB | Output is correct |
97 | Correct | 96 ms | 11584 KB | Output is correct |
98 | Correct | 87 ms | 11524 KB | Output is correct |
99 | Correct | 90 ms | 11716 KB | Output is correct |
100 | Correct | 90 ms | 11616 KB | Output is correct |
101 | Correct | 90 ms | 11592 KB | Output is correct |
102 | Correct | 89 ms | 11632 KB | Output is correct |
103 | Correct | 90 ms | 11560 KB | Output is correct |
104 | Correct | 90 ms | 11608 KB | Output is correct |
105 | Correct | 91 ms | 11584 KB | Output is correct |
106 | Correct | 94 ms | 13276 KB | Output is correct |
107 | Correct | 92 ms | 13176 KB | Output is correct |
108 | Correct | 96 ms | 13144 KB | Output is correct |
109 | Correct | 91 ms | 13120 KB | Output is correct |
110 | Correct | 93 ms | 13116 KB | Output is correct |
111 | Correct | 93 ms | 13172 KB | Output is correct |
112 | Correct | 95 ms | 13120 KB | Output is correct |
113 | Correct | 99 ms | 13208 KB | Output is correct |
114 | Correct | 96 ms | 13128 KB | Output is correct |
115 | Correct | 92 ms | 13120 KB | Output is correct |
116 | Incorrect | 1 ms | 312 KB | Output isn't correct |
117 | Halted | 0 ms | 0 KB | - |