제출 #1333916

#제출 시각아이디문제언어결과실행 시간메모리
1333916hmms127서열 (APIO23_sequence)C++20
28 / 100
2096 ms29768 KiB
#include "sequence.h"
#include <vector>
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
// for ordered set or indexed set
using ordered_set= tree<key, null_type, less_equal<key>, rb_tree_tag, tree_order_statistics_node_update>; // less_equal
int sequence(int n, vector<int> a) {
    int ans=0;
    for (int l=0;l<n;l++) {
        ordered_set<int>ot;vector<int>frq(n+1,0);
        for (int r=l;r<n;r++) {
            ot.insert(a[r]);
            frq[a[r]]++;
            if ((r-l+1)%2) {
                int x=*ot.find_by_order((int)(ot.size()/2));
                ans=max(ans,frq[x]);
            }
            else ans=max({ans,frq[*ot.find_by_order((int)(ot.size()/2))],frq[*ot.find_by_order((int)(ot.size()/2)-1)]});
        }
    }
    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...