Submission #977740

#TimeUsernameProblemLanguageResultExecution timeMemory
977740UnforgettableplSequence (APIO23_sequence)C++17
28 / 100
2099 ms68500 KiB
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

#define int long long

int32_t sequence(int32_t N, std::vector<int32_t> A) {
    int32_t ans = 0;
    for(int i=0;i<N;i++){
        int k = 0;
        map<int,int32_t> freq;
        ordered_set window;
        for(int j=i;j<N;j++){
            k++;freq[A[j]]++;window.insert({A[j],j});
            ans=max(freq[(*window.find_by_order(k/2)).first],ans);
            if(k%2==0) {
                ans=max(freq[(*window.find_by_order((k/2)-1)).first],ans);
            }
        }
    }
    return ans;
}

//int32_t main() {
//    int32_t N;
//    assert(1 == scanf("%d", &N));
//
//    std::vector<int32_t> A(N);
//    for (int32_t i = 0; i < N; ++i) {
//        assert(1 == scanf("%d", &A[i]));
//    }
//
//    int32_t result = sequence(N, A);
//    printf("%d\n", result);
//    return 0;
//}
#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...