답안 #1034079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034079 2024-07-25T09:34:36 Z vjudge1 Diversity (CEOI21_diversity) C++17
38 / 100
49 ms 1576 KB
#include <bits/stdc++.h>
using namespace std;

string abc = "abcdefghijklmnopqrstuvwxyz";

#define int long long

int m = 1003;

void solve(){
    int n, q;
    cin >> n >> q;
    // vector<int> v(n);
    vector<int> a(m, 0);
    int r;
    int sz = 0;
    for(int i = 0; i < n; i++){
        cin >> r;
        if(a[r]==0) sz++;
        a[r]++;
    }
    cin >> q >> q;
    vector<int> w, v(sz);
    for(int i = 0; i < m; i++){
        if(a[i] != 0){
            w.push_back(a[i]);
        }
    }
    sort(w.rbegin(), w.rend());
    int st = sz/2;
    v[st]=w[0];
    st--;
    int res = 2;
    for(int i = 1; i < sz; i++){
        v[st]=w[i];
        if(i%2 == 0) st-=res;
        else st+=res;
        res++;
    }

    int ans = 0;
    n = v.size();
    for(int i = 0; i < n; i++){
        ans+=v[i]*(v[i]+1)/2;
    }
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            ans+=(j-i+1)*v[i]*v[j];
        }
    }

    cout << ans << endl;
    

}


signed main(){
    int t = 1;

    while(t--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
5 Correct 16 ms 604 KB Output is correct
6 Correct 26 ms 1000 KB Output is correct
7 Correct 24 ms 860 KB Output is correct
8 Correct 24 ms 860 KB Output is correct
9 Correct 25 ms 860 KB Output is correct
10 Correct 27 ms 860 KB Output is correct
11 Correct 25 ms 932 KB Output is correct
12 Correct 26 ms 1116 KB Output is correct
13 Correct 25 ms 1052 KB Output is correct
14 Correct 24 ms 1060 KB Output is correct
15 Correct 25 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
5 Correct 16 ms 604 KB Output is correct
6 Correct 26 ms 1000 KB Output is correct
7 Correct 24 ms 860 KB Output is correct
8 Correct 24 ms 860 KB Output is correct
9 Correct 25 ms 860 KB Output is correct
10 Correct 27 ms 860 KB Output is correct
11 Correct 25 ms 932 KB Output is correct
12 Correct 26 ms 1116 KB Output is correct
13 Correct 25 ms 1052 KB Output is correct
14 Correct 24 ms 1060 KB Output is correct
15 Correct 25 ms 860 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 10 ms 604 KB Output is correct
20 Correct 19 ms 932 KB Output is correct
21 Correct 28 ms 1116 KB Output is correct
22 Correct 28 ms 1192 KB Output is correct
23 Correct 28 ms 1364 KB Output is correct
24 Correct 28 ms 1108 KB Output is correct
25 Correct 29 ms 1112 KB Output is correct
26 Correct 30 ms 1112 KB Output is correct
27 Correct 29 ms 1112 KB Output is correct
28 Correct 27 ms 1116 KB Output is correct
29 Correct 27 ms 1108 KB Output is correct
30 Correct 28 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
5 Correct 16 ms 604 KB Output is correct
6 Correct 26 ms 1000 KB Output is correct
7 Correct 24 ms 860 KB Output is correct
8 Correct 24 ms 860 KB Output is correct
9 Correct 25 ms 860 KB Output is correct
10 Correct 27 ms 860 KB Output is correct
11 Correct 25 ms 932 KB Output is correct
12 Correct 26 ms 1116 KB Output is correct
13 Correct 25 ms 1052 KB Output is correct
14 Correct 24 ms 1060 KB Output is correct
15 Correct 25 ms 860 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 10 ms 604 KB Output is correct
20 Correct 19 ms 932 KB Output is correct
21 Correct 28 ms 1116 KB Output is correct
22 Correct 28 ms 1192 KB Output is correct
23 Correct 28 ms 1364 KB Output is correct
24 Correct 28 ms 1108 KB Output is correct
25 Correct 29 ms 1112 KB Output is correct
26 Correct 30 ms 1112 KB Output is correct
27 Correct 29 ms 1112 KB Output is correct
28 Correct 27 ms 1116 KB Output is correct
29 Correct 27 ms 1108 KB Output is correct
30 Correct 28 ms 1116 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 6 ms 604 KB Output is correct
38 Correct 6 ms 604 KB Output is correct
39 Correct 12 ms 604 KB Output is correct
40 Correct 23 ms 1116 KB Output is correct
41 Correct 45 ms 1364 KB Output is correct
42 Correct 40 ms 1372 KB Output is correct
43 Correct 34 ms 1364 KB Output is correct
44 Correct 34 ms 1364 KB Output is correct
45 Correct 34 ms 1372 KB Output is correct
46 Correct 34 ms 1364 KB Output is correct
47 Correct 34 ms 1372 KB Output is correct
48 Correct 35 ms 1364 KB Output is correct
49 Correct 34 ms 1360 KB Output is correct
50 Correct 34 ms 1364 KB Output is correct
51 Correct 35 ms 1364 KB Output is correct
52 Correct 34 ms 1552 KB Output is correct
53 Correct 34 ms 1372 KB Output is correct
54 Correct 35 ms 1576 KB Output is correct
55 Correct 34 ms 1372 KB Output is correct
56 Correct 41 ms 1360 KB Output is correct
57 Correct 34 ms 1364 KB Output is correct
58 Correct 49 ms 1364 KB Output is correct
59 Correct 34 ms 1360 KB Output is correct
60 Correct 34 ms 1564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 16 ms 604 KB Output is correct
16 Correct 26 ms 1000 KB Output is correct
17 Correct 24 ms 860 KB Output is correct
18 Correct 24 ms 860 KB Output is correct
19 Correct 25 ms 860 KB Output is correct
20 Correct 27 ms 860 KB Output is correct
21 Correct 25 ms 932 KB Output is correct
22 Correct 26 ms 1116 KB Output is correct
23 Correct 25 ms 1052 KB Output is correct
24 Correct 24 ms 1060 KB Output is correct
25 Correct 25 ms 860 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 19 ms 932 KB Output is correct
31 Correct 28 ms 1116 KB Output is correct
32 Correct 28 ms 1192 KB Output is correct
33 Correct 28 ms 1364 KB Output is correct
34 Correct 28 ms 1108 KB Output is correct
35 Correct 29 ms 1112 KB Output is correct
36 Correct 30 ms 1112 KB Output is correct
37 Correct 29 ms 1112 KB Output is correct
38 Correct 27 ms 1116 KB Output is correct
39 Correct 27 ms 1108 KB Output is correct
40 Correct 28 ms 1116 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 6 ms 604 KB Output is correct
48 Correct 6 ms 604 KB Output is correct
49 Correct 12 ms 604 KB Output is correct
50 Correct 23 ms 1116 KB Output is correct
51 Correct 45 ms 1364 KB Output is correct
52 Correct 40 ms 1372 KB Output is correct
53 Correct 34 ms 1364 KB Output is correct
54 Correct 34 ms 1364 KB Output is correct
55 Correct 34 ms 1372 KB Output is correct
56 Correct 34 ms 1364 KB Output is correct
57 Correct 34 ms 1372 KB Output is correct
58 Correct 35 ms 1364 KB Output is correct
59 Correct 34 ms 1360 KB Output is correct
60 Correct 34 ms 1364 KB Output is correct
61 Correct 35 ms 1364 KB Output is correct
62 Correct 34 ms 1552 KB Output is correct
63 Correct 34 ms 1372 KB Output is correct
64 Correct 35 ms 1576 KB Output is correct
65 Correct 34 ms 1372 KB Output is correct
66 Correct 41 ms 1360 KB Output is correct
67 Correct 34 ms 1364 KB Output is correct
68 Correct 49 ms 1364 KB Output is correct
69 Correct 34 ms 1360 KB Output is correct
70 Correct 34 ms 1564 KB Output is correct
71 Incorrect 8 ms 600 KB Output isn't correct
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 604 KB Output is correct
15 Correct 16 ms 604 KB Output is correct
16 Correct 26 ms 1000 KB Output is correct
17 Correct 24 ms 860 KB Output is correct
18 Correct 24 ms 860 KB Output is correct
19 Correct 25 ms 860 KB Output is correct
20 Correct 27 ms 860 KB Output is correct
21 Correct 25 ms 932 KB Output is correct
22 Correct 26 ms 1116 KB Output is correct
23 Correct 25 ms 1052 KB Output is correct
24 Correct 24 ms 1060 KB Output is correct
25 Correct 25 ms 860 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 19 ms 932 KB Output is correct
31 Correct 28 ms 1116 KB Output is correct
32 Correct 28 ms 1192 KB Output is correct
33 Correct 28 ms 1364 KB Output is correct
34 Correct 28 ms 1108 KB Output is correct
35 Correct 29 ms 1112 KB Output is correct
36 Correct 30 ms 1112 KB Output is correct
37 Correct 29 ms 1112 KB Output is correct
38 Correct 27 ms 1116 KB Output is correct
39 Correct 27 ms 1108 KB Output is correct
40 Correct 28 ms 1116 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 6 ms 604 KB Output is correct
48 Correct 6 ms 604 KB Output is correct
49 Correct 12 ms 604 KB Output is correct
50 Correct 23 ms 1116 KB Output is correct
51 Correct 45 ms 1364 KB Output is correct
52 Correct 40 ms 1372 KB Output is correct
53 Correct 34 ms 1364 KB Output is correct
54 Correct 34 ms 1364 KB Output is correct
55 Correct 34 ms 1372 KB Output is correct
56 Correct 34 ms 1364 KB Output is correct
57 Correct 34 ms 1372 KB Output is correct
58 Correct 35 ms 1364 KB Output is correct
59 Correct 34 ms 1360 KB Output is correct
60 Correct 34 ms 1364 KB Output is correct
61 Correct 35 ms 1364 KB Output is correct
62 Correct 34 ms 1552 KB Output is correct
63 Correct 34 ms 1372 KB Output is correct
64 Correct 35 ms 1576 KB Output is correct
65 Correct 34 ms 1372 KB Output is correct
66 Correct 41 ms 1360 KB Output is correct
67 Correct 34 ms 1364 KB Output is correct
68 Correct 49 ms 1364 KB Output is correct
69 Correct 34 ms 1360 KB Output is correct
70 Correct 34 ms 1564 KB Output is correct
71 Incorrect 8 ms 600 KB Output isn't correct
72 Halted 0 ms 0 KB -