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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef
tree<
pair<int,int>,
null_type,
less<pair<int,int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;
int sequence(int N, std::vector<int> A) {
ll ans = 1;
for(int i=0; i<N; i++){
ordered_set s;
multiset<ll> s2;
for(int j=i; j<N; j++){
s.insert({A[j], j});
s2.insert(A[j]);
ll siz = j-i+1;
if(siz%2==1){
ll medind = floor(siz/2);
auto it = s.find_by_order(medind);
ll medval = (*it).first;
ll temp = s2.count(medval);
ans = max(ans, temp);
} else {
ll medind1 = siz/2;
ll medind2 = (siz/2)-1;
auto it1 = s.find_by_order(medind1);
auto it2 = s.find_by_order(medind2);
ll medval1 = (*it1).first;
ll medval2 = (*it2).first;
ll temp1 = s2.count(medval1);
ll temp2 = s2.count(medval2);
ll temp = max(temp1, temp2);
ans = max(ans, temp);
}
}
// for(auto u : s){
// cout << u.first << " " << u.second << endl;
// }
// cout<<endl;
}
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... |