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 sequence(int n, vector<int> a)
{
int pos = 0;
vector<int> b = a;
sort(b.begin(), b.end());
int min_median = b[n / 2];
for(int i = 0; i < n - 1; i++)
{
if(a[i] <= a[i + 1])
{
continue;
}
else
{
pos = i;
break;
}
}
for(int i = n - 1; i > 1; i--)
{
if(a[i] <= a[i - 1])
{
continue;
}
else
{
pos = i;
break;
}
}
map<int, int> freq1, freq2;
for(int i = 0; i <= pos; i++)
{
freq1[a[i]]++;
}
for(int i = n - 1; i > pos; i--)
{
freq2[a[i]]++;
}
int ans = 0;
for(int i = 1; i <= n; i++)
{
if(i < min_median)
{
ans = max(ans, max(freq1[i], freq2[i]));
}
else
{
ans = max(ans, freq1[i] + freq2[i]);
}
}
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... |