답안 #549526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549526 2022-04-16T02:25:43 Z minhcool Diversity (CEOI21_diversity) C++17
64 / 100
91 ms 11828 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 4e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, q, a[N];

ii cnt[N];

void process(){
    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        cnt[a[i]].fi++;
    }
    for(int i = 1; i <= 300000; i++) cnt[i].se = i;
    sort(cnt + 1, cnt + 300000 + 1, greater<ii>());
    deque<int> dq;
    for(int i = 1; i <= 300000; i++){
        if(i & 1) for(int j = 1; j <= cnt[i].fi; j++) dq.push_front(cnt[i].se);
        else for(int j = 1; j <= cnt[i].fi; j++) dq.push_back(cnt[i].se);
    }
    int cnt = 0, tol = 0, lst = -1, tol2 = 0;
    //cout << dq.size() << "\n";
    while(dq.size()){
        int u = dq.front();
        //cout << u << "\n";
        dq.pop_front();
        cnt++;
        if(lst != u) tol += cnt;
        else tol++;
        tol2 += tol;
        lst = u;
    }
    cout << tol2 << "\n";
}

signed main(){
    ios_base::sync_with_stdio(0);
    process();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4948 KB Output is correct
2 Correct 36 ms 5008 KB Output is correct
3 Correct 36 ms 5016 KB Output is correct
4 Correct 33 ms 4948 KB Output is correct
5 Correct 35 ms 4984 KB Output is correct
6 Correct 37 ms 4948 KB Output is correct
7 Correct 38 ms 4948 KB Output is correct
8 Correct 37 ms 5012 KB Output is correct
9 Correct 39 ms 4948 KB Output is correct
10 Correct 35 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 4940 KB Output is correct
2 Correct 39 ms 5032 KB Output is correct
3 Correct 40 ms 5124 KB Output is correct
4 Correct 48 ms 6776 KB Output is correct
5 Correct 61 ms 8532 KB Output is correct
6 Correct 51 ms 10432 KB Output is correct
7 Correct 50 ms 10436 KB Output is correct
8 Correct 53 ms 10440 KB Output is correct
9 Correct 56 ms 10424 KB Output is correct
10 Correct 64 ms 10460 KB Output is correct
11 Correct 61 ms 10440 KB Output is correct
12 Correct 60 ms 10460 KB Output is correct
13 Correct 52 ms 10440 KB Output is correct
14 Correct 52 ms 10448 KB Output is correct
15 Correct 57 ms 10424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 4940 KB Output is correct
2 Correct 39 ms 5032 KB Output is correct
3 Correct 40 ms 5124 KB Output is correct
4 Correct 48 ms 6776 KB Output is correct
5 Correct 61 ms 8532 KB Output is correct
6 Correct 51 ms 10432 KB Output is correct
7 Correct 50 ms 10436 KB Output is correct
8 Correct 53 ms 10440 KB Output is correct
9 Correct 56 ms 10424 KB Output is correct
10 Correct 64 ms 10460 KB Output is correct
11 Correct 61 ms 10440 KB Output is correct
12 Correct 60 ms 10460 KB Output is correct
13 Correct 52 ms 10440 KB Output is correct
14 Correct 52 ms 10448 KB Output is correct
15 Correct 57 ms 10424 KB Output is correct
16 Correct 37 ms 4948 KB Output is correct
17 Correct 36 ms 5004 KB Output is correct
18 Correct 40 ms 5132 KB Output is correct
19 Correct 45 ms 6848 KB Output is correct
20 Correct 49 ms 8652 KB Output is correct
21 Correct 54 ms 10648 KB Output is correct
22 Correct 56 ms 10576 KB Output is correct
23 Correct 53 ms 10572 KB Output is correct
24 Correct 61 ms 10572 KB Output is correct
25 Correct 57 ms 10584 KB Output is correct
26 Correct 54 ms 10544 KB Output is correct
27 Correct 60 ms 10496 KB Output is correct
28 Correct 53 ms 10532 KB Output is correct
29 Correct 74 ms 10480 KB Output is correct
30 Correct 61 ms 10580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 4940 KB Output is correct
2 Correct 39 ms 5032 KB Output is correct
3 Correct 40 ms 5124 KB Output is correct
4 Correct 48 ms 6776 KB Output is correct
5 Correct 61 ms 8532 KB Output is correct
6 Correct 51 ms 10432 KB Output is correct
7 Correct 50 ms 10436 KB Output is correct
8 Correct 53 ms 10440 KB Output is correct
9 Correct 56 ms 10424 KB Output is correct
10 Correct 64 ms 10460 KB Output is correct
11 Correct 61 ms 10440 KB Output is correct
12 Correct 60 ms 10460 KB Output is correct
13 Correct 52 ms 10440 KB Output is correct
14 Correct 52 ms 10448 KB Output is correct
15 Correct 57 ms 10424 KB Output is correct
16 Correct 37 ms 4948 KB Output is correct
17 Correct 36 ms 5004 KB Output is correct
18 Correct 40 ms 5132 KB Output is correct
19 Correct 45 ms 6848 KB Output is correct
20 Correct 49 ms 8652 KB Output is correct
21 Correct 54 ms 10648 KB Output is correct
22 Correct 56 ms 10576 KB Output is correct
23 Correct 53 ms 10572 KB Output is correct
24 Correct 61 ms 10572 KB Output is correct
25 Correct 57 ms 10584 KB Output is correct
26 Correct 54 ms 10544 KB Output is correct
27 Correct 60 ms 10496 KB Output is correct
28 Correct 53 ms 10532 KB Output is correct
29 Correct 74 ms 10480 KB Output is correct
30 Correct 61 ms 10580 KB Output is correct
31 Correct 36 ms 4948 KB Output is correct
32 Correct 36 ms 4948 KB Output is correct
33 Correct 38 ms 5040 KB Output is correct
34 Correct 34 ms 5144 KB Output is correct
35 Correct 34 ms 5148 KB Output is correct
36 Correct 35 ms 5136 KB Output is correct
37 Correct 44 ms 6000 KB Output is correct
38 Correct 49 ms 6004 KB Output is correct
39 Correct 48 ms 6968 KB Output is correct
40 Correct 50 ms 8884 KB Output is correct
41 Correct 58 ms 10980 KB Output is correct
42 Correct 61 ms 10956 KB Output is correct
43 Correct 63 ms 10932 KB Output is correct
44 Correct 75 ms 10964 KB Output is correct
45 Correct 58 ms 10940 KB Output is correct
46 Correct 63 ms 10936 KB Output is correct
47 Correct 66 ms 10936 KB Output is correct
48 Correct 68 ms 10936 KB Output is correct
49 Correct 66 ms 10936 KB Output is correct
50 Correct 57 ms 10952 KB Output is correct
51 Correct 56 ms 10972 KB Output is correct
52 Correct 67 ms 10940 KB Output is correct
53 Correct 72 ms 10924 KB Output is correct
54 Correct 64 ms 10864 KB Output is correct
55 Correct 62 ms 10848 KB Output is correct
56 Correct 60 ms 10936 KB Output is correct
57 Correct 58 ms 10932 KB Output is correct
58 Correct 74 ms 10936 KB Output is correct
59 Correct 59 ms 10916 KB Output is correct
60 Correct 59 ms 10948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4948 KB Output is correct
2 Correct 36 ms 5008 KB Output is correct
3 Correct 36 ms 5016 KB Output is correct
4 Correct 33 ms 4948 KB Output is correct
5 Correct 35 ms 4984 KB Output is correct
6 Correct 37 ms 4948 KB Output is correct
7 Correct 38 ms 4948 KB Output is correct
8 Correct 37 ms 5012 KB Output is correct
9 Correct 39 ms 4948 KB Output is correct
10 Correct 35 ms 4948 KB Output is correct
11 Correct 34 ms 4940 KB Output is correct
12 Correct 39 ms 5032 KB Output is correct
13 Correct 40 ms 5124 KB Output is correct
14 Correct 48 ms 6776 KB Output is correct
15 Correct 61 ms 8532 KB Output is correct
16 Correct 51 ms 10432 KB Output is correct
17 Correct 50 ms 10436 KB Output is correct
18 Correct 53 ms 10440 KB Output is correct
19 Correct 56 ms 10424 KB Output is correct
20 Correct 64 ms 10460 KB Output is correct
21 Correct 61 ms 10440 KB Output is correct
22 Correct 60 ms 10460 KB Output is correct
23 Correct 52 ms 10440 KB Output is correct
24 Correct 52 ms 10448 KB Output is correct
25 Correct 57 ms 10424 KB Output is correct
26 Correct 37 ms 4948 KB Output is correct
27 Correct 36 ms 5004 KB Output is correct
28 Correct 40 ms 5132 KB Output is correct
29 Correct 45 ms 6848 KB Output is correct
30 Correct 49 ms 8652 KB Output is correct
31 Correct 54 ms 10648 KB Output is correct
32 Correct 56 ms 10576 KB Output is correct
33 Correct 53 ms 10572 KB Output is correct
34 Correct 61 ms 10572 KB Output is correct
35 Correct 57 ms 10584 KB Output is correct
36 Correct 54 ms 10544 KB Output is correct
37 Correct 60 ms 10496 KB Output is correct
38 Correct 53 ms 10532 KB Output is correct
39 Correct 74 ms 10480 KB Output is correct
40 Correct 61 ms 10580 KB Output is correct
41 Correct 36 ms 4948 KB Output is correct
42 Correct 36 ms 4948 KB Output is correct
43 Correct 38 ms 5040 KB Output is correct
44 Correct 34 ms 5144 KB Output is correct
45 Correct 34 ms 5148 KB Output is correct
46 Correct 35 ms 5136 KB Output is correct
47 Correct 44 ms 6000 KB Output is correct
48 Correct 49 ms 6004 KB Output is correct
49 Correct 48 ms 6968 KB Output is correct
50 Correct 50 ms 8884 KB Output is correct
51 Correct 58 ms 10980 KB Output is correct
52 Correct 61 ms 10956 KB Output is correct
53 Correct 63 ms 10932 KB Output is correct
54 Correct 75 ms 10964 KB Output is correct
55 Correct 58 ms 10940 KB Output is correct
56 Correct 63 ms 10936 KB Output is correct
57 Correct 66 ms 10936 KB Output is correct
58 Correct 68 ms 10936 KB Output is correct
59 Correct 66 ms 10936 KB Output is correct
60 Correct 57 ms 10952 KB Output is correct
61 Correct 56 ms 10972 KB Output is correct
62 Correct 67 ms 10940 KB Output is correct
63 Correct 72 ms 10924 KB Output is correct
64 Correct 64 ms 10864 KB Output is correct
65 Correct 62 ms 10848 KB Output is correct
66 Correct 60 ms 10936 KB Output is correct
67 Correct 58 ms 10932 KB Output is correct
68 Correct 74 ms 10936 KB Output is correct
69 Correct 59 ms 10916 KB Output is correct
70 Correct 59 ms 10948 KB Output is correct
71 Correct 41 ms 6008 KB Output is correct
72 Correct 41 ms 5996 KB Output is correct
73 Correct 42 ms 6012 KB Output is correct
74 Correct 40 ms 6032 KB Output is correct
75 Correct 41 ms 5964 KB Output is correct
76 Correct 47 ms 7036 KB Output is correct
77 Correct 49 ms 7036 KB Output is correct
78 Correct 54 ms 7040 KB Output is correct
79 Correct 46 ms 7036 KB Output is correct
80 Correct 41 ms 6992 KB Output is correct
81 Correct 49 ms 9088 KB Output is correct
82 Correct 66 ms 9092 KB Output is correct
83 Correct 60 ms 9076 KB Output is correct
84 Correct 60 ms 9088 KB Output is correct
85 Correct 49 ms 9160 KB Output is correct
86 Correct 54 ms 9256 KB Output is correct
87 Correct 56 ms 9292 KB Output is correct
88 Correct 53 ms 9180 KB Output is correct
89 Correct 57 ms 9192 KB Output is correct
90 Correct 55 ms 9184 KB Output is correct
91 Correct 59 ms 11480 KB Output is correct
92 Correct 58 ms 11500 KB Output is correct
93 Correct 65 ms 11572 KB Output is correct
94 Correct 63 ms 11556 KB Output is correct
95 Correct 61 ms 11548 KB Output is correct
96 Correct 71 ms 11624 KB Output is correct
97 Correct 64 ms 11688 KB Output is correct
98 Correct 61 ms 11680 KB Output is correct
99 Correct 63 ms 11604 KB Output is correct
100 Correct 51 ms 11692 KB Output is correct
101 Correct 60 ms 11692 KB Output is correct
102 Correct 66 ms 11692 KB Output is correct
103 Correct 63 ms 11692 KB Output is correct
104 Correct 91 ms 11680 KB Output is correct
105 Correct 65 ms 11620 KB Output is correct
106 Correct 50 ms 11784 KB Output is correct
107 Correct 55 ms 11724 KB Output is correct
108 Correct 63 ms 11724 KB Output is correct
109 Correct 65 ms 11672 KB Output is correct
110 Correct 61 ms 11720 KB Output is correct
111 Correct 53 ms 11760 KB Output is correct
112 Correct 53 ms 11680 KB Output is correct
113 Correct 51 ms 11696 KB Output is correct
114 Correct 86 ms 11828 KB Output is correct
115 Correct 80 ms 11652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4948 KB Output is correct
2 Correct 36 ms 5008 KB Output is correct
3 Correct 36 ms 5016 KB Output is correct
4 Correct 33 ms 4948 KB Output is correct
5 Correct 35 ms 4984 KB Output is correct
6 Correct 37 ms 4948 KB Output is correct
7 Correct 38 ms 4948 KB Output is correct
8 Correct 37 ms 5012 KB Output is correct
9 Correct 39 ms 4948 KB Output is correct
10 Correct 35 ms 4948 KB Output is correct
11 Correct 34 ms 4940 KB Output is correct
12 Correct 39 ms 5032 KB Output is correct
13 Correct 40 ms 5124 KB Output is correct
14 Correct 48 ms 6776 KB Output is correct
15 Correct 61 ms 8532 KB Output is correct
16 Correct 51 ms 10432 KB Output is correct
17 Correct 50 ms 10436 KB Output is correct
18 Correct 53 ms 10440 KB Output is correct
19 Correct 56 ms 10424 KB Output is correct
20 Correct 64 ms 10460 KB Output is correct
21 Correct 61 ms 10440 KB Output is correct
22 Correct 60 ms 10460 KB Output is correct
23 Correct 52 ms 10440 KB Output is correct
24 Correct 52 ms 10448 KB Output is correct
25 Correct 57 ms 10424 KB Output is correct
26 Correct 37 ms 4948 KB Output is correct
27 Correct 36 ms 5004 KB Output is correct
28 Correct 40 ms 5132 KB Output is correct
29 Correct 45 ms 6848 KB Output is correct
30 Correct 49 ms 8652 KB Output is correct
31 Correct 54 ms 10648 KB Output is correct
32 Correct 56 ms 10576 KB Output is correct
33 Correct 53 ms 10572 KB Output is correct
34 Correct 61 ms 10572 KB Output is correct
35 Correct 57 ms 10584 KB Output is correct
36 Correct 54 ms 10544 KB Output is correct
37 Correct 60 ms 10496 KB Output is correct
38 Correct 53 ms 10532 KB Output is correct
39 Correct 74 ms 10480 KB Output is correct
40 Correct 61 ms 10580 KB Output is correct
41 Correct 36 ms 4948 KB Output is correct
42 Correct 36 ms 4948 KB Output is correct
43 Correct 38 ms 5040 KB Output is correct
44 Correct 34 ms 5144 KB Output is correct
45 Correct 34 ms 5148 KB Output is correct
46 Correct 35 ms 5136 KB Output is correct
47 Correct 44 ms 6000 KB Output is correct
48 Correct 49 ms 6004 KB Output is correct
49 Correct 48 ms 6968 KB Output is correct
50 Correct 50 ms 8884 KB Output is correct
51 Correct 58 ms 10980 KB Output is correct
52 Correct 61 ms 10956 KB Output is correct
53 Correct 63 ms 10932 KB Output is correct
54 Correct 75 ms 10964 KB Output is correct
55 Correct 58 ms 10940 KB Output is correct
56 Correct 63 ms 10936 KB Output is correct
57 Correct 66 ms 10936 KB Output is correct
58 Correct 68 ms 10936 KB Output is correct
59 Correct 66 ms 10936 KB Output is correct
60 Correct 57 ms 10952 KB Output is correct
61 Correct 56 ms 10972 KB Output is correct
62 Correct 67 ms 10940 KB Output is correct
63 Correct 72 ms 10924 KB Output is correct
64 Correct 64 ms 10864 KB Output is correct
65 Correct 62 ms 10848 KB Output is correct
66 Correct 60 ms 10936 KB Output is correct
67 Correct 58 ms 10932 KB Output is correct
68 Correct 74 ms 10936 KB Output is correct
69 Correct 59 ms 10916 KB Output is correct
70 Correct 59 ms 10948 KB Output is correct
71 Correct 41 ms 6008 KB Output is correct
72 Correct 41 ms 5996 KB Output is correct
73 Correct 42 ms 6012 KB Output is correct
74 Correct 40 ms 6032 KB Output is correct
75 Correct 41 ms 5964 KB Output is correct
76 Correct 47 ms 7036 KB Output is correct
77 Correct 49 ms 7036 KB Output is correct
78 Correct 54 ms 7040 KB Output is correct
79 Correct 46 ms 7036 KB Output is correct
80 Correct 41 ms 6992 KB Output is correct
81 Correct 49 ms 9088 KB Output is correct
82 Correct 66 ms 9092 KB Output is correct
83 Correct 60 ms 9076 KB Output is correct
84 Correct 60 ms 9088 KB Output is correct
85 Correct 49 ms 9160 KB Output is correct
86 Correct 54 ms 9256 KB Output is correct
87 Correct 56 ms 9292 KB Output is correct
88 Correct 53 ms 9180 KB Output is correct
89 Correct 57 ms 9192 KB Output is correct
90 Correct 55 ms 9184 KB Output is correct
91 Correct 59 ms 11480 KB Output is correct
92 Correct 58 ms 11500 KB Output is correct
93 Correct 65 ms 11572 KB Output is correct
94 Correct 63 ms 11556 KB Output is correct
95 Correct 61 ms 11548 KB Output is correct
96 Correct 71 ms 11624 KB Output is correct
97 Correct 64 ms 11688 KB Output is correct
98 Correct 61 ms 11680 KB Output is correct
99 Correct 63 ms 11604 KB Output is correct
100 Correct 51 ms 11692 KB Output is correct
101 Correct 60 ms 11692 KB Output is correct
102 Correct 66 ms 11692 KB Output is correct
103 Correct 63 ms 11692 KB Output is correct
104 Correct 91 ms 11680 KB Output is correct
105 Correct 65 ms 11620 KB Output is correct
106 Correct 50 ms 11784 KB Output is correct
107 Correct 55 ms 11724 KB Output is correct
108 Correct 63 ms 11724 KB Output is correct
109 Correct 65 ms 11672 KB Output is correct
110 Correct 61 ms 11720 KB Output is correct
111 Correct 53 ms 11760 KB Output is correct
112 Correct 53 ms 11680 KB Output is correct
113 Correct 51 ms 11696 KB Output is correct
114 Correct 86 ms 11828 KB Output is correct
115 Correct 80 ms 11652 KB Output is correct
116 Incorrect 34 ms 5204 KB Output isn't correct
117 Halted 0 ms 0 KB -