Submission #981924

#TimeUsernameProblemLanguageResultExecution timeMemory
981924vjudge1Sequence (APIO23_sequence)C++17
11 / 100
2054 ms9068 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; int n; int arr[100000]; int nums[100000]; int calcula(int l, int r){ int t=r-l+1; for(int i=l, pos=0; i<=r; i++) nums[pos++]=arr[i]; sort(nums, nums+t); int a=-1, b=-1; if(t%2==0){ a=nums[t/2-1]; b=nums[t/2]; } else{ a=nums[t/2]; } int cnt1=0, cnt2=0; for(int i=0; i<t; i++){ if(nums[i]==a) cnt1++; if(nums[i]==b) cnt2++; } return max(cnt1, cnt2); } int sequence(int N, std::vector<int> A) { n=N; for(int i=0; i<n; i++) arr[i]=A[i]; int ans=0; for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ int x=calcula(i, j); ans=max(ans, x); } } 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...