| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361699 | jackhui100101 | Sequence (APIO23_sequence) | C++20 | 2096 ms | 10236 KiB |
#include "sequence.h"
#include <bits/stdc++.h>
using namespace std;
int sequence(int n, vector<int> a) {
int ans = 1;
vector<int> cnt(n + 1);
for (int i = 0; i < n; i++){
for (int j = 1; j <= n; j++){
cnt[j] = 0;
}
priority_queue<int> minq;
priority_queue<int, vector<int>, greater<int>> maxq;
for (int j = i; j < n; j++){
cnt[a[j]]++;
int m1 = 0, m2 = 0;
if (minq.size() + maxq.size() == 0){
minq.push(a[j]);
m1 = minq.top();
}
else if (minq.size() == maxq.size()){
if (a[j] <= minq.top()){
minq.push(a[j]);
m1 = minq.top();
}
else{
maxq.push(a[j]);
m1 = maxq.top();
}
}
else{
if (minq.size() > maxq.size()){
if (a[j] <= minq.top()){
maxq.push(minq.top());
minq.pop();
minq.push(a[j]);
}
else{
maxq.push(a[j]);
}
}
else{
if (a[j] >= maxq.top()){
minq.push(maxq.top());
maxq.pop();
maxq.push(a[j]);
}
else{
minq.push(a[j]);
}
}
m1 = minq.top();
m2 = maxq.top();
}
ans = max(ans, max(cnt[m1], cnt[m2]));
}
}
return ans;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
