| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333916 | hmms127 | Sequence (APIO23_sequence) | C++20 | 2096 ms | 29768 KiB |
#include "sequence.h"
#include <vector>
#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;
template<typename key>
// for ordered set or indexed set
using ordered_set= tree<key, null_type, less_equal<key>, rb_tree_tag, tree_order_statistics_node_update>; // less_equal
int sequence(int n, vector<int> a) {
int ans=0;
for (int l=0;l<n;l++) {
ordered_set<int>ot;vector<int>frq(n+1,0);
for (int r=l;r<n;r++) {
ot.insert(a[r]);
frq[a[r]]++;
if ((r-l+1)%2) {
int x=*ot.find_by_order((int)(ot.size()/2));
ans=max(ans,frq[x]);
}
else ans=max({ans,frq[*ot.find_by_order((int)(ot.size()/2))],frq[*ot.find_by_order((int)(ot.size()/2)-1)]});
}
}
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... | ||||
