Submission #1336296

#TimeUsernameProblemLanguageResultExecution timeMemory
1336296MunkhErdeneSequence (APIO23_sequence)C++17
28 / 100
2096 ms37596 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define _ << " " <<
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ull unsigned long long
#define lll __int128
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define BlueCrowner ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll naim = 1e9;
const ll max_bit = 60;
const ull tom = ULLONG_MAX;
const ll MAXN = 100005;
const ll LOG = 20;
const ll NAIM = 1e18;
const ll N = 2e6 + 5;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int sequence(int n, vector<int> a) {
    ll i, j;
    int ans = 0;
    FOR(i, 0, n) {
        indexed_set<pair<int,int>> st;
        vector<int> cnt(n + 1, 0);
        FOR(j, i, n) {
        st.insert({a[j], j});
        cnt[a[j]]++;
        int l = j - i + 1;
        auto L = *st.find_by_order((l - 1) / 2);
        auto R = *st.find_by_order(l / 2);

        int x = L.first;
        int y = R.first;

        ans = max(ans, max(cnt[x], cnt[y]));
        }
    }

  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...