# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
954252 | Trisanu_Das | Sequence (APIO23_sequence) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#include "sequence.h"
using namespace std;
int sequence(int n, vector<int> n){
int ans = 0;
for(int i = 0; i < n; i++){
int s = 0, c = 0;
for(int j = i; j > -1; j--){
if(a[i] == a[j]) c++;
if(a[i] > a[j]) s--;
if(a[i] < a[j]) s++;
if(abs(s) <= c) ans = max(ans, c);
}
}
return ans;
}