This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "sequence.h"
#include <bits/stdc++.h>
using namespace std;
int freq[500005];
vector<int> b;
int sequence(int n, vector<int> a)
{
for (int i=0; i<n; i++)
freq[a[i]]++;
b=a;
sort(b.begin(), b.end());
int cnt=1, ans=0;
for (int i=(n-1)/2; i<n; i++)
ans=max(ans, freq[b[i]]);
for (int i=1; i<n; i++)
{
if (a[i]==a[i-1])
cnt++;
else
{
ans=max(ans, cnt);
cnt=1;
}
}
ans=max(ans, cnt);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |