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