#include "sequence.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;
signed sequence(signed N, std::vector<signed> A) {
int ans = 0;
for (int v = 1;v <= N;v++) {
for (int l = 1;l<=N;l++) {
int p = 0,s = 0,c = 0;
for (int r = l;r<=N;r++) {
if (A[r-1] < v) s++;
if (A[r-1] > v) p++;
if (A[r-1] == v) c++;
if (2*max(p,s) <= r-l+1) {
if (A[l-1] == v || A[r-1] == v) {
ans = max(ans,c);
}
}
}
}
}
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... |