Submission #613612

# Submission time Handle Problem Language Result Execution time Memory
613612 2022-07-30T07:43:49 Z yuto1115 Diversity (CEOI21_diversity) C++17
64 / 100
188 ms 14428 KB
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); ++i)
#define rrep(i, n) for(ll i = ll(n) - 1; i >= 0; --i)
#define rrep2(i, n, t) for(ll i = ll(n) - 1; i >= ll(t); --i)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define SZ(a) int(a.size())
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
const int inf = 1001001001;
const ll linf = 1001001001001001001;

template<class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vi a(n);
    map<int, int> mp;
    for (int &i: a) {
        cin >> i;
        ++mp[i];
    }
    vi ls;
    for (auto[f, s]: mp) ls.pb(s);
    sort(all(ls));
    ls.pop_back();
    vi v(2);
    ll ans = 0;
    for (int i: ls) {
        v[0] += i;
        ans += (ll) v[0] * (n - v[0]);
        swap(v[0], v[1]);
    }
    rep(i, 2) assert(v[i] <= n / 2);
    ans += (ll) n * (n + 1) / 2;
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 724 KB Output is correct
5 Correct 12 ms 1116 KB Output is correct
6 Correct 19 ms 1504 KB Output is correct
7 Correct 16 ms 1508 KB Output is correct
8 Correct 18 ms 1504 KB Output is correct
9 Correct 18 ms 1492 KB Output is correct
10 Correct 17 ms 1512 KB Output is correct
11 Correct 18 ms 1508 KB Output is correct
12 Correct 21 ms 1492 KB Output is correct
13 Correct 19 ms 1512 KB Output is correct
14 Correct 17 ms 1492 KB Output is correct
15 Correct 28 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 724 KB Output is correct
5 Correct 12 ms 1116 KB Output is correct
6 Correct 19 ms 1504 KB Output is correct
7 Correct 16 ms 1508 KB Output is correct
8 Correct 18 ms 1504 KB Output is correct
9 Correct 18 ms 1492 KB Output is correct
10 Correct 17 ms 1512 KB Output is correct
11 Correct 18 ms 1508 KB Output is correct
12 Correct 21 ms 1492 KB Output is correct
13 Correct 19 ms 1512 KB Output is correct
14 Correct 17 ms 1492 KB Output is correct
15 Correct 28 ms 1492 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 7 ms 724 KB Output is correct
20 Correct 14 ms 1116 KB Output is correct
21 Correct 23 ms 1508 KB Output is correct
22 Correct 21 ms 1500 KB Output is correct
23 Correct 20 ms 1500 KB Output is correct
24 Correct 21 ms 1492 KB Output is correct
25 Correct 22 ms 1504 KB Output is correct
26 Correct 24 ms 1508 KB Output is correct
27 Correct 23 ms 1492 KB Output is correct
28 Correct 20 ms 1492 KB Output is correct
29 Correct 21 ms 1508 KB Output is correct
30 Correct 21 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 724 KB Output is correct
5 Correct 12 ms 1116 KB Output is correct
6 Correct 19 ms 1504 KB Output is correct
7 Correct 16 ms 1508 KB Output is correct
8 Correct 18 ms 1504 KB Output is correct
9 Correct 18 ms 1492 KB Output is correct
10 Correct 17 ms 1512 KB Output is correct
11 Correct 18 ms 1508 KB Output is correct
12 Correct 21 ms 1492 KB Output is correct
13 Correct 19 ms 1512 KB Output is correct
14 Correct 17 ms 1492 KB Output is correct
15 Correct 28 ms 1492 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 7 ms 724 KB Output is correct
20 Correct 14 ms 1116 KB Output is correct
21 Correct 23 ms 1508 KB Output is correct
22 Correct 21 ms 1500 KB Output is correct
23 Correct 20 ms 1500 KB Output is correct
24 Correct 21 ms 1492 KB Output is correct
25 Correct 22 ms 1504 KB Output is correct
26 Correct 24 ms 1508 KB Output is correct
27 Correct 23 ms 1492 KB Output is correct
28 Correct 20 ms 1492 KB Output is correct
29 Correct 21 ms 1508 KB Output is correct
30 Correct 21 ms 1492 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 6 ms 468 KB Output is correct
38 Correct 6 ms 468 KB Output is correct
39 Correct 11 ms 776 KB Output is correct
40 Correct 23 ms 1172 KB Output is correct
41 Correct 35 ms 1492 KB Output is correct
42 Correct 34 ms 1528 KB Output is correct
43 Correct 34 ms 1492 KB Output is correct
44 Correct 33 ms 1544 KB Output is correct
45 Correct 33 ms 1492 KB Output is correct
46 Correct 33 ms 1492 KB Output is correct
47 Correct 34 ms 1556 KB Output is correct
48 Correct 34 ms 1492 KB Output is correct
49 Correct 33 ms 1532 KB Output is correct
50 Correct 35 ms 1492 KB Output is correct
51 Correct 34 ms 1492 KB Output is correct
52 Correct 33 ms 1492 KB Output is correct
53 Correct 35 ms 1492 KB Output is correct
54 Correct 35 ms 1544 KB Output is correct
55 Correct 34 ms 1492 KB Output is correct
56 Correct 35 ms 1552 KB Output is correct
57 Correct 33 ms 1492 KB Output is correct
58 Correct 34 ms 1492 KB Output is correct
59 Correct 33 ms 1492 KB Output is correct
60 Correct 34 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 7 ms 724 KB Output is correct
15 Correct 12 ms 1116 KB Output is correct
16 Correct 19 ms 1504 KB Output is correct
17 Correct 16 ms 1508 KB Output is correct
18 Correct 18 ms 1504 KB Output is correct
19 Correct 18 ms 1492 KB Output is correct
20 Correct 17 ms 1512 KB Output is correct
21 Correct 18 ms 1508 KB Output is correct
22 Correct 21 ms 1492 KB Output is correct
23 Correct 19 ms 1512 KB Output is correct
24 Correct 17 ms 1492 KB Output is correct
25 Correct 28 ms 1492 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 7 ms 724 KB Output is correct
30 Correct 14 ms 1116 KB Output is correct
31 Correct 23 ms 1508 KB Output is correct
32 Correct 21 ms 1500 KB Output is correct
33 Correct 20 ms 1500 KB Output is correct
34 Correct 21 ms 1492 KB Output is correct
35 Correct 22 ms 1504 KB Output is correct
36 Correct 24 ms 1508 KB Output is correct
37 Correct 23 ms 1492 KB Output is correct
38 Correct 20 ms 1492 KB Output is correct
39 Correct 21 ms 1508 KB Output is correct
40 Correct 21 ms 1492 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 2 ms 364 KB Output is correct
47 Correct 6 ms 468 KB Output is correct
48 Correct 6 ms 468 KB Output is correct
49 Correct 11 ms 776 KB Output is correct
50 Correct 23 ms 1172 KB Output is correct
51 Correct 35 ms 1492 KB Output is correct
52 Correct 34 ms 1528 KB Output is correct
53 Correct 34 ms 1492 KB Output is correct
54 Correct 33 ms 1544 KB Output is correct
55 Correct 33 ms 1492 KB Output is correct
56 Correct 33 ms 1492 KB Output is correct
57 Correct 34 ms 1556 KB Output is correct
58 Correct 34 ms 1492 KB Output is correct
59 Correct 33 ms 1532 KB Output is correct
60 Correct 35 ms 1492 KB Output is correct
61 Correct 34 ms 1492 KB Output is correct
62 Correct 33 ms 1492 KB Output is correct
63 Correct 35 ms 1492 KB Output is correct
64 Correct 35 ms 1544 KB Output is correct
65 Correct 34 ms 1492 KB Output is correct
66 Correct 35 ms 1552 KB Output is correct
67 Correct 33 ms 1492 KB Output is correct
68 Correct 34 ms 1492 KB Output is correct
69 Correct 33 ms 1492 KB Output is correct
70 Correct 34 ms 1492 KB Output is correct
71 Correct 7 ms 596 KB Output is correct
72 Correct 7 ms 600 KB Output is correct
73 Correct 7 ms 596 KB Output is correct
74 Correct 8 ms 624 KB Output is correct
75 Correct 7 ms 624 KB Output is correct
76 Correct 16 ms 956 KB Output is correct
77 Correct 16 ms 956 KB Output is correct
78 Correct 17 ms 980 KB Output is correct
79 Correct 16 ms 948 KB Output is correct
80 Correct 15 ms 912 KB Output is correct
81 Correct 34 ms 1612 KB Output is correct
82 Correct 36 ms 1612 KB Output is correct
83 Correct 37 ms 1564 KB Output is correct
84 Correct 37 ms 1580 KB Output is correct
85 Correct 36 ms 1576 KB Output is correct
86 Correct 58 ms 2124 KB Output is correct
87 Correct 41 ms 2120 KB Output is correct
88 Correct 42 ms 2160 KB Output is correct
89 Correct 44 ms 2124 KB Output is correct
90 Correct 43 ms 2236 KB Output is correct
91 Correct 100 ms 6752 KB Output is correct
92 Correct 118 ms 6744 KB Output is correct
93 Correct 101 ms 6712 KB Output is correct
94 Correct 104 ms 6736 KB Output is correct
95 Correct 92 ms 6752 KB Output is correct
96 Correct 162 ms 11932 KB Output is correct
97 Correct 150 ms 12004 KB Output is correct
98 Correct 152 ms 11960 KB Output is correct
99 Correct 148 ms 12112 KB Output is correct
100 Correct 153 ms 11932 KB Output is correct
101 Correct 155 ms 12020 KB Output is correct
102 Correct 147 ms 11952 KB Output is correct
103 Correct 151 ms 12000 KB Output is correct
104 Correct 149 ms 12068 KB Output is correct
105 Correct 154 ms 12032 KB Output is correct
106 Correct 169 ms 14280 KB Output is correct
107 Correct 176 ms 14312 KB Output is correct
108 Correct 176 ms 14280 KB Output is correct
109 Correct 170 ms 14336 KB Output is correct
110 Correct 173 ms 14272 KB Output is correct
111 Correct 188 ms 14320 KB Output is correct
112 Correct 181 ms 14264 KB Output is correct
113 Correct 174 ms 14312 KB Output is correct
114 Correct 178 ms 14364 KB Output is correct
115 Correct 182 ms 14428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 7 ms 724 KB Output is correct
15 Correct 12 ms 1116 KB Output is correct
16 Correct 19 ms 1504 KB Output is correct
17 Correct 16 ms 1508 KB Output is correct
18 Correct 18 ms 1504 KB Output is correct
19 Correct 18 ms 1492 KB Output is correct
20 Correct 17 ms 1512 KB Output is correct
21 Correct 18 ms 1508 KB Output is correct
22 Correct 21 ms 1492 KB Output is correct
23 Correct 19 ms 1512 KB Output is correct
24 Correct 17 ms 1492 KB Output is correct
25 Correct 28 ms 1492 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 7 ms 724 KB Output is correct
30 Correct 14 ms 1116 KB Output is correct
31 Correct 23 ms 1508 KB Output is correct
32 Correct 21 ms 1500 KB Output is correct
33 Correct 20 ms 1500 KB Output is correct
34 Correct 21 ms 1492 KB Output is correct
35 Correct 22 ms 1504 KB Output is correct
36 Correct 24 ms 1508 KB Output is correct
37 Correct 23 ms 1492 KB Output is correct
38 Correct 20 ms 1492 KB Output is correct
39 Correct 21 ms 1508 KB Output is correct
40 Correct 21 ms 1492 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 2 ms 364 KB Output is correct
47 Correct 6 ms 468 KB Output is correct
48 Correct 6 ms 468 KB Output is correct
49 Correct 11 ms 776 KB Output is correct
50 Correct 23 ms 1172 KB Output is correct
51 Correct 35 ms 1492 KB Output is correct
52 Correct 34 ms 1528 KB Output is correct
53 Correct 34 ms 1492 KB Output is correct
54 Correct 33 ms 1544 KB Output is correct
55 Correct 33 ms 1492 KB Output is correct
56 Correct 33 ms 1492 KB Output is correct
57 Correct 34 ms 1556 KB Output is correct
58 Correct 34 ms 1492 KB Output is correct
59 Correct 33 ms 1532 KB Output is correct
60 Correct 35 ms 1492 KB Output is correct
61 Correct 34 ms 1492 KB Output is correct
62 Correct 33 ms 1492 KB Output is correct
63 Correct 35 ms 1492 KB Output is correct
64 Correct 35 ms 1544 KB Output is correct
65 Correct 34 ms 1492 KB Output is correct
66 Correct 35 ms 1552 KB Output is correct
67 Correct 33 ms 1492 KB Output is correct
68 Correct 34 ms 1492 KB Output is correct
69 Correct 33 ms 1492 KB Output is correct
70 Correct 34 ms 1492 KB Output is correct
71 Correct 7 ms 596 KB Output is correct
72 Correct 7 ms 600 KB Output is correct
73 Correct 7 ms 596 KB Output is correct
74 Correct 8 ms 624 KB Output is correct
75 Correct 7 ms 624 KB Output is correct
76 Correct 16 ms 956 KB Output is correct
77 Correct 16 ms 956 KB Output is correct
78 Correct 17 ms 980 KB Output is correct
79 Correct 16 ms 948 KB Output is correct
80 Correct 15 ms 912 KB Output is correct
81 Correct 34 ms 1612 KB Output is correct
82 Correct 36 ms 1612 KB Output is correct
83 Correct 37 ms 1564 KB Output is correct
84 Correct 37 ms 1580 KB Output is correct
85 Correct 36 ms 1576 KB Output is correct
86 Correct 58 ms 2124 KB Output is correct
87 Correct 41 ms 2120 KB Output is correct
88 Correct 42 ms 2160 KB Output is correct
89 Correct 44 ms 2124 KB Output is correct
90 Correct 43 ms 2236 KB Output is correct
91 Correct 100 ms 6752 KB Output is correct
92 Correct 118 ms 6744 KB Output is correct
93 Correct 101 ms 6712 KB Output is correct
94 Correct 104 ms 6736 KB Output is correct
95 Correct 92 ms 6752 KB Output is correct
96 Correct 162 ms 11932 KB Output is correct
97 Correct 150 ms 12004 KB Output is correct
98 Correct 152 ms 11960 KB Output is correct
99 Correct 148 ms 12112 KB Output is correct
100 Correct 153 ms 11932 KB Output is correct
101 Correct 155 ms 12020 KB Output is correct
102 Correct 147 ms 11952 KB Output is correct
103 Correct 151 ms 12000 KB Output is correct
104 Correct 149 ms 12068 KB Output is correct
105 Correct 154 ms 12032 KB Output is correct
106 Correct 169 ms 14280 KB Output is correct
107 Correct 176 ms 14312 KB Output is correct
108 Correct 176 ms 14280 KB Output is correct
109 Correct 170 ms 14336 KB Output is correct
110 Correct 173 ms 14272 KB Output is correct
111 Correct 188 ms 14320 KB Output is correct
112 Correct 181 ms 14264 KB Output is correct
113 Correct 174 ms 14312 KB Output is correct
114 Correct 178 ms 14364 KB Output is correct
115 Correct 182 ms 14428 KB Output is correct
116 Incorrect 1 ms 340 KB Output isn't correct
117 Halted 0 ms 0 KB -