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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int sequence(int n, vector <int> a){
vector <vector <int>> repe(n+1, vector<int>(n+1));
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
repe[i][j] = repe[i][j-1] + (a[j-1] == i);
}
}
int ans = 0;
for(int i=0; i<n; i++){
ordered_set st;
for(int j=i; j<n; j++){
st.insert(a[j]);
int x = st.order_of_key((j-i)/2);
int y = st.order_of_key((j-i+1)/2);
ans = max(ans, repe[x][j+1]-repe[x][i]);
ans = max(ans, repe[y][j+1]-repe[y][i]);
}
st.clear();
}
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... |