제출 #1191341

#제출 시각아이디문제언어결과실행 시간메모리
1191341just서열 (APIO23_sequence)C++20
28 / 100
2098 ms59016 KiB
#include "bits/stdc++.h"
using namespace std;

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

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

#define vec vector

int sequence(int N, std::vector<int> A) {

    int ans = 0;
    for(int i = 0; i < N; i++) {
        auto tree = ordered_set<pair<int,int>>();
        map<int,int> f;
        for(int j = i; j < N; j++) {
            tree.insert({A[j], j});
            f[A[j]]++;

            if (tree.size() % 2 == 0) {
                int a = tree.find_by_order(tree.size() / 2 - 1)->first;
                int b = tree.find_by_order(tree.size() / 2)->first;
                ans = max(ans, f[a]);
                ans = max(ans, f[b]);
            } else {
                int a = tree.find_by_order(tree.size() / 2)->first;
                ans = max(ans, f[a]);
            }
        }
    }

    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...