This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <cassert>
#include <fstream>
#include "sequence.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
mt19937 rnd(7069);
typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef float fl;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define all(x) (x).begin(), (x).end()
const int MAX = int(2e9 + 5);
const ll MAXL = ll(1e18) + 5ll;
const int N = 500005;
int a[N];
int n;
int sol1() {
int len;
vi cnt(n + 1);
int ret = 0;
for (int i = 1; i <= n; ++i) {
indexed_set s;
cnt.assign(n + 1, 0);
len = 0;
for (int j = i; j <= n; ++j) {
++cnt[a[j]];
++len;
s.insert(a[j]);
auto x = s.find_by_order((len - 1) / 2);
if (cnt[*x] > ret) ret = cnt[*x];
auto y = s.find_by_order((len - 1) / 2 + (len - 1) % 2);
if (cnt[*y] > ret) ret = cnt[*y];
}
}
return ret;
}
int sequence(int N, std::vector<int> A) {
n = N;
for (int i = 1; i <= n; ++i) {
a[i] = A[i - 1];
}
if (n <= 2000) {
return sol1();
}
}
Compilation message (stderr)
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:90:1: warning: control reaches end of non-void function [-Wreturn-type]
90 | }
| ^
# | 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... |