Submission #977754

#TimeUsernameProblemLanguageResultExecution timeMemory
977754UnforgettableplSequence (APIO23_sequence)C++17
7 / 100
299 ms38736 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t sequence(int32_t N, std::vector<int32_t> A) {
    int32_t ans = 0;
    map<int,int32_t > freq;
    int32_t curr = 1;freq[A[0]]++;
    for(int i=1;i<N;i++){
        freq[A[i]]++;
        if(A[i]==A[i-1]){
            curr++;
        } else {
            ans = max(ans,curr);
            curr = 1;
        }
    }
    ans = max(ans,curr);
    int k = N/2;
    if(N%2==0)k--;
    int currless = 0;
    for(auto[val,fre]:freq){
        currless+=fre;
        if(k<currless)ans = max(ans,fre);
    }
    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...