Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
0
Indexable
Never
#include <bits/stdc++.h>

using namespace std;
typedef int32_t ll;
vector<ll> t(4 * 2000001);
//vector<ll> dat;

ll get_min(ll p, ll l, ll r, ll a, ll b) {
    if (r <= a || l >= b) {
        return 0;
    }
    if (l >= a && r <= b) {
        return t[p];
    }
    ll m = (r + l) / 2;
    ll gt1 = get_min(2 * p + 1, l, m, a, b), gt2 = get_min(2 * p + 2, m, r, a, b);
    return gt1 + gt2;
}

void update(ll p, ll l, ll r, ll pos) {
    if (r - l == 1 && l == pos) {
        t[p] = 1;
        return;
    }
    if (pos < l || pos >= r) {
        return;
    }
    ll m = (r + l) / 2;
    update(2 * p + 1, l, m, pos);
    update(2 * p + 2, m, r, pos);
    t[p] = t[2 * p + 1] + t[2 * p + 2];
}

int main() {
    ll n, is = 0;
    cin >> n;
    vector<ll> a(n);
    set<ll> b;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b.insert(a[i]);
    }
    ll ans = 0;
    for(auto it = b.begin(); it != b.end(); it ++){
        ll siz = *it, loc_ans = 0, flag = 0;
        set<ll> used;
        for(int i = 0; i < n; i++){
            if(a[i] == siz && flag == 1){
                loc_ans ++;
            }
            if(a[i] == siz && flag == 0){
                flag = 1;
                loc_ans ++;
            }
            if(flag == 0 && used.find(a[i]) == used.end()){
                used.insert(a[i]);
                loc_ans ++;
            }

        }
        ans = max(ans, loc_ans);
    }
    cout << ans;
}