답안 #1114493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114493 2024-11-19T06:08:13 Z vjudge1 Diversity (CEOI21_diversity) C++17
64 / 100
179 ms 23536 KB
#include <bits/stdc++.h>
#define pb push_back
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define mid (l+r)/2
#define inf 1e15
#define MOD 998244353
#define MX 200005
using namespace std;



void solve(){
    int n,q; cin >> n >> q;
    int arr[n+1];
    map<int, int> cnt;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    for(int i=1; i<=q; i++){int a,b; cin >> a >> b;}
    vi wow;
    for(auto p:cnt) wow.pb(p.nd);
    sort(all(wow));
    int p1=0, p2=0, ans=n*(n+1)/2;
    for(int i=0; i<wow.size()-1; i++){
        if(p1>p2) swap(p1,p2);
        p1+=wow[i];
        ans+=p1*(n-p1);
    }
    cout << ans << endl;
}


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    /*#else
    freopen("248.in","r",stdin);
    freopen("248.out","w",stdout);*/
    #endif


    int t=1;
    //cin >> t;
    while(t--) solve();
}

Compilation message

diversity.cpp: In function 'void solve()':
diversity.cpp:33:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0; i<wow.size()-1; i++){
      |                  ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 7 ms 1360 KB Output is correct
5 Correct 12 ms 2384 KB Output is correct
6 Correct 19 ms 3408 KB Output is correct
7 Correct 17 ms 3408 KB Output is correct
8 Correct 18 ms 3408 KB Output is correct
9 Correct 17 ms 3296 KB Output is correct
10 Correct 17 ms 3576 KB Output is correct
11 Correct 20 ms 3408 KB Output is correct
12 Correct 19 ms 3408 KB Output is correct
13 Correct 25 ms 3408 KB Output is correct
14 Correct 17 ms 3408 KB Output is correct
15 Correct 18 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 7 ms 1360 KB Output is correct
5 Correct 12 ms 2384 KB Output is correct
6 Correct 19 ms 3408 KB Output is correct
7 Correct 17 ms 3408 KB Output is correct
8 Correct 18 ms 3408 KB Output is correct
9 Correct 17 ms 3296 KB Output is correct
10 Correct 17 ms 3576 KB Output is correct
11 Correct 20 ms 3408 KB Output is correct
12 Correct 19 ms 3408 KB Output is correct
13 Correct 25 ms 3408 KB Output is correct
14 Correct 17 ms 3408 KB Output is correct
15 Correct 18 ms 3428 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 560 KB Output is correct
19 Correct 8 ms 1360 KB Output is correct
20 Correct 14 ms 2644 KB Output is correct
21 Correct 19 ms 3432 KB Output is correct
22 Correct 20 ms 3428 KB Output is correct
23 Correct 18 ms 3408 KB Output is correct
24 Correct 19 ms 3408 KB Output is correct
25 Correct 20 ms 3576 KB Output is correct
26 Correct 19 ms 3576 KB Output is correct
27 Correct 19 ms 3408 KB Output is correct
28 Correct 20 ms 3408 KB Output is correct
29 Correct 21 ms 3408 KB Output is correct
30 Correct 26 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 7 ms 1360 KB Output is correct
5 Correct 12 ms 2384 KB Output is correct
6 Correct 19 ms 3408 KB Output is correct
7 Correct 17 ms 3408 KB Output is correct
8 Correct 18 ms 3408 KB Output is correct
9 Correct 17 ms 3296 KB Output is correct
10 Correct 17 ms 3576 KB Output is correct
11 Correct 20 ms 3408 KB Output is correct
12 Correct 19 ms 3408 KB Output is correct
13 Correct 25 ms 3408 KB Output is correct
14 Correct 17 ms 3408 KB Output is correct
15 Correct 18 ms 3428 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 560 KB Output is correct
19 Correct 8 ms 1360 KB Output is correct
20 Correct 14 ms 2644 KB Output is correct
21 Correct 19 ms 3432 KB Output is correct
22 Correct 20 ms 3428 KB Output is correct
23 Correct 18 ms 3408 KB Output is correct
24 Correct 19 ms 3408 KB Output is correct
25 Correct 20 ms 3576 KB Output is correct
26 Correct 19 ms 3576 KB Output is correct
27 Correct 19 ms 3408 KB Output is correct
28 Correct 20 ms 3408 KB Output is correct
29 Correct 21 ms 3408 KB Output is correct
30 Correct 26 ms 3428 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 592 KB Output is correct
35 Correct 2 ms 760 KB Output is correct
36 Correct 3 ms 760 KB Output is correct
37 Correct 6 ms 848 KB Output is correct
38 Correct 7 ms 1268 KB Output is correct
39 Correct 12 ms 1664 KB Output is correct
40 Correct 22 ms 2712 KB Output is correct
41 Correct 32 ms 3996 KB Output is correct
42 Correct 32 ms 3932 KB Output is correct
43 Correct 33 ms 3988 KB Output is correct
44 Correct 30 ms 3920 KB Output is correct
45 Correct 32 ms 3920 KB Output is correct
46 Correct 32 ms 3920 KB Output is correct
47 Correct 31 ms 3920 KB Output is correct
48 Correct 36 ms 3996 KB Output is correct
49 Correct 32 ms 4004 KB Output is correct
50 Correct 36 ms 4004 KB Output is correct
51 Correct 32 ms 3944 KB Output is correct
52 Correct 31 ms 4000 KB Output is correct
53 Correct 31 ms 3920 KB Output is correct
54 Correct 31 ms 3992 KB Output is correct
55 Correct 29 ms 4088 KB Output is correct
56 Correct 32 ms 3920 KB Output is correct
57 Correct 30 ms 3932 KB Output is correct
58 Correct 30 ms 3912 KB Output is correct
59 Correct 32 ms 3920 KB Output is correct
60 Correct 32 ms 3920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 7 ms 1360 KB Output is correct
15 Correct 12 ms 2384 KB Output is correct
16 Correct 19 ms 3408 KB Output is correct
17 Correct 17 ms 3408 KB Output is correct
18 Correct 18 ms 3408 KB Output is correct
19 Correct 17 ms 3296 KB Output is correct
20 Correct 17 ms 3576 KB Output is correct
21 Correct 20 ms 3408 KB Output is correct
22 Correct 19 ms 3408 KB Output is correct
23 Correct 25 ms 3408 KB Output is correct
24 Correct 17 ms 3408 KB Output is correct
25 Correct 18 ms 3428 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 2 ms 560 KB Output is correct
29 Correct 8 ms 1360 KB Output is correct
30 Correct 14 ms 2644 KB Output is correct
31 Correct 19 ms 3432 KB Output is correct
32 Correct 20 ms 3428 KB Output is correct
33 Correct 18 ms 3408 KB Output is correct
34 Correct 19 ms 3408 KB Output is correct
35 Correct 20 ms 3576 KB Output is correct
36 Correct 19 ms 3576 KB Output is correct
37 Correct 19 ms 3408 KB Output is correct
38 Correct 20 ms 3408 KB Output is correct
39 Correct 21 ms 3408 KB Output is correct
40 Correct 26 ms 3428 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 760 KB Output is correct
46 Correct 3 ms 760 KB Output is correct
47 Correct 6 ms 848 KB Output is correct
48 Correct 7 ms 1268 KB Output is correct
49 Correct 12 ms 1664 KB Output is correct
50 Correct 22 ms 2712 KB Output is correct
51 Correct 32 ms 3996 KB Output is correct
52 Correct 32 ms 3932 KB Output is correct
53 Correct 33 ms 3988 KB Output is correct
54 Correct 30 ms 3920 KB Output is correct
55 Correct 32 ms 3920 KB Output is correct
56 Correct 32 ms 3920 KB Output is correct
57 Correct 31 ms 3920 KB Output is correct
58 Correct 36 ms 3996 KB Output is correct
59 Correct 32 ms 4004 KB Output is correct
60 Correct 36 ms 4004 KB Output is correct
61 Correct 32 ms 3944 KB Output is correct
62 Correct 31 ms 4000 KB Output is correct
63 Correct 31 ms 3920 KB Output is correct
64 Correct 31 ms 3992 KB Output is correct
65 Correct 29 ms 4088 KB Output is correct
66 Correct 32 ms 3920 KB Output is correct
67 Correct 30 ms 3932 KB Output is correct
68 Correct 30 ms 3912 KB Output is correct
69 Correct 32 ms 3920 KB Output is correct
70 Correct 32 ms 3920 KB Output is correct
71 Correct 7 ms 1104 KB Output is correct
72 Correct 7 ms 1104 KB Output is correct
73 Correct 7 ms 1104 KB Output is correct
74 Correct 7 ms 1272 KB Output is correct
75 Correct 8 ms 1104 KB Output is correct
76 Correct 14 ms 1872 KB Output is correct
77 Correct 15 ms 2128 KB Output is correct
78 Correct 15 ms 2128 KB Output is correct
79 Correct 16 ms 1896 KB Output is correct
80 Correct 15 ms 2128 KB Output is correct
81 Correct 36 ms 3664 KB Output is correct
82 Correct 35 ms 3656 KB Output is correct
83 Correct 37 ms 3692 KB Output is correct
84 Correct 36 ms 3696 KB Output is correct
85 Correct 37 ms 3664 KB Output is correct
86 Correct 46 ms 4680 KB Output is correct
87 Correct 51 ms 4680 KB Output is correct
88 Correct 42 ms 4564 KB Output is correct
89 Correct 45 ms 4692 KB Output is correct
90 Correct 47 ms 4612 KB Output is correct
91 Correct 104 ms 11712 KB Output is correct
92 Correct 102 ms 11712 KB Output is correct
93 Correct 105 ms 11724 KB Output is correct
94 Correct 106 ms 11712 KB Output is correct
95 Correct 102 ms 11712 KB Output is correct
96 Correct 136 ms 20372 KB Output is correct
97 Correct 119 ms 20412 KB Output is correct
98 Correct 123 ms 20412 KB Output is correct
99 Correct 138 ms 20180 KB Output is correct
100 Correct 126 ms 20412 KB Output is correct
101 Correct 118 ms 20412 KB Output is correct
102 Correct 118 ms 20412 KB Output is correct
103 Correct 120 ms 20412 KB Output is correct
104 Correct 121 ms 20412 KB Output is correct
105 Correct 120 ms 20412 KB Output is correct
106 Correct 159 ms 23484 KB Output is correct
107 Correct 150 ms 23412 KB Output is correct
108 Correct 141 ms 23484 KB Output is correct
109 Correct 148 ms 23536 KB Output is correct
110 Correct 157 ms 23484 KB Output is correct
111 Correct 173 ms 23484 KB Output is correct
112 Correct 161 ms 23368 KB Output is correct
113 Correct 179 ms 23484 KB Output is correct
114 Correct 178 ms 23484 KB Output is correct
115 Correct 165 ms 23484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 7 ms 1360 KB Output is correct
15 Correct 12 ms 2384 KB Output is correct
16 Correct 19 ms 3408 KB Output is correct
17 Correct 17 ms 3408 KB Output is correct
18 Correct 18 ms 3408 KB Output is correct
19 Correct 17 ms 3296 KB Output is correct
20 Correct 17 ms 3576 KB Output is correct
21 Correct 20 ms 3408 KB Output is correct
22 Correct 19 ms 3408 KB Output is correct
23 Correct 25 ms 3408 KB Output is correct
24 Correct 17 ms 3408 KB Output is correct
25 Correct 18 ms 3428 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 2 ms 560 KB Output is correct
29 Correct 8 ms 1360 KB Output is correct
30 Correct 14 ms 2644 KB Output is correct
31 Correct 19 ms 3432 KB Output is correct
32 Correct 20 ms 3428 KB Output is correct
33 Correct 18 ms 3408 KB Output is correct
34 Correct 19 ms 3408 KB Output is correct
35 Correct 20 ms 3576 KB Output is correct
36 Correct 19 ms 3576 KB Output is correct
37 Correct 19 ms 3408 KB Output is correct
38 Correct 20 ms 3408 KB Output is correct
39 Correct 21 ms 3408 KB Output is correct
40 Correct 26 ms 3428 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 2 ms 592 KB Output is correct
45 Correct 2 ms 760 KB Output is correct
46 Correct 3 ms 760 KB Output is correct
47 Correct 6 ms 848 KB Output is correct
48 Correct 7 ms 1268 KB Output is correct
49 Correct 12 ms 1664 KB Output is correct
50 Correct 22 ms 2712 KB Output is correct
51 Correct 32 ms 3996 KB Output is correct
52 Correct 32 ms 3932 KB Output is correct
53 Correct 33 ms 3988 KB Output is correct
54 Correct 30 ms 3920 KB Output is correct
55 Correct 32 ms 3920 KB Output is correct
56 Correct 32 ms 3920 KB Output is correct
57 Correct 31 ms 3920 KB Output is correct
58 Correct 36 ms 3996 KB Output is correct
59 Correct 32 ms 4004 KB Output is correct
60 Correct 36 ms 4004 KB Output is correct
61 Correct 32 ms 3944 KB Output is correct
62 Correct 31 ms 4000 KB Output is correct
63 Correct 31 ms 3920 KB Output is correct
64 Correct 31 ms 3992 KB Output is correct
65 Correct 29 ms 4088 KB Output is correct
66 Correct 32 ms 3920 KB Output is correct
67 Correct 30 ms 3932 KB Output is correct
68 Correct 30 ms 3912 KB Output is correct
69 Correct 32 ms 3920 KB Output is correct
70 Correct 32 ms 3920 KB Output is correct
71 Correct 7 ms 1104 KB Output is correct
72 Correct 7 ms 1104 KB Output is correct
73 Correct 7 ms 1104 KB Output is correct
74 Correct 7 ms 1272 KB Output is correct
75 Correct 8 ms 1104 KB Output is correct
76 Correct 14 ms 1872 KB Output is correct
77 Correct 15 ms 2128 KB Output is correct
78 Correct 15 ms 2128 KB Output is correct
79 Correct 16 ms 1896 KB Output is correct
80 Correct 15 ms 2128 KB Output is correct
81 Correct 36 ms 3664 KB Output is correct
82 Correct 35 ms 3656 KB Output is correct
83 Correct 37 ms 3692 KB Output is correct
84 Correct 36 ms 3696 KB Output is correct
85 Correct 37 ms 3664 KB Output is correct
86 Correct 46 ms 4680 KB Output is correct
87 Correct 51 ms 4680 KB Output is correct
88 Correct 42 ms 4564 KB Output is correct
89 Correct 45 ms 4692 KB Output is correct
90 Correct 47 ms 4612 KB Output is correct
91 Correct 104 ms 11712 KB Output is correct
92 Correct 102 ms 11712 KB Output is correct
93 Correct 105 ms 11724 KB Output is correct
94 Correct 106 ms 11712 KB Output is correct
95 Correct 102 ms 11712 KB Output is correct
96 Correct 136 ms 20372 KB Output is correct
97 Correct 119 ms 20412 KB Output is correct
98 Correct 123 ms 20412 KB Output is correct
99 Correct 138 ms 20180 KB Output is correct
100 Correct 126 ms 20412 KB Output is correct
101 Correct 118 ms 20412 KB Output is correct
102 Correct 118 ms 20412 KB Output is correct
103 Correct 120 ms 20412 KB Output is correct
104 Correct 121 ms 20412 KB Output is correct
105 Correct 120 ms 20412 KB Output is correct
106 Correct 159 ms 23484 KB Output is correct
107 Correct 150 ms 23412 KB Output is correct
108 Correct 141 ms 23484 KB Output is correct
109 Correct 148 ms 23536 KB Output is correct
110 Correct 157 ms 23484 KB Output is correct
111 Correct 173 ms 23484 KB Output is correct
112 Correct 161 ms 23368 KB Output is correct
113 Correct 179 ms 23484 KB Output is correct
114 Correct 178 ms 23484 KB Output is correct
115 Correct 165 ms 23484 KB Output is correct
116 Incorrect 6 ms 848 KB Output isn't correct
117 Halted 0 ms 0 KB -