| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1.5 초 | 1024 MB | 50 | 16 | 14 | 31.818% |
In the enchanting realm of APIO, there lived a young and brilliant student named Alice. Alice had an insatiable curiosity for solving intriguing problems that challenged her mathematical prowess. One day, she stumbled upon a mystical series of numbers with a length of $N$ (that is $A[0],ドル $A[1],ドル $\cdots,ドル $A[N - 1]$), and she couldn't resist the allure of exploring its secrets.
Here, she wants to share with you some of her discoveries. But before that, for your convenience, we need to define some things:
Alice is eager to find the maximum value of $\displaystyle\max_{x \in S(l,r)}{W(l, r,x)},ドル where 0ドル ≤ l ≤ r ≤ N - 1,ドル as it poses a challenging task. The term $S(l, r)$ represents the set of medians derived from $A[l] \cdots A[r]$ (as previously mentioned as $S(A[l], \cdots ,A[r])$). Although Alice has already obtained the answer, she seeks assistance in verifying it and kindly requests your help in programming the calculation.
You should implement the following procedure:
int sequence(int N, std::vector<int> A);
Consider the following call:
sequence(7, {1, 2, 3, 1, 2, 1, 3});
This procedure should return 3ドル$.
In this case, $S(0, 5) = \{1, 2\},ドル $W(0, 5, 1) = 3,ドル $W(0, 5, 2) = 2$. So the value of $(0, 5)$ is 3ドル$.
It is easy to verify that $(0, 5)$ has the greatest value among all possible pairs.
Consider the following call:
sequence(9, {1, 1, 2, 3, 4, 3, 2, 1, 1});
This procedure should return 2.
Consider the following call:
sequence(14, {2, 6, 2, 5, 3, 4, 2, 1, 4, 3, 5, 6, 3, 2});
This procedure should return 3ドル$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 11 | $N ≤ 100$. |
| 2 | 17 | $N ≤ 2 \times 10^3$. |
| 3 | 7 | There exists an $x$ that satisfy $∀0 ≤ i < x, A[i] ≤ A[i + 1]$ and $∀x < i < N, A[i] ≤ A[i - 1]$. |
| 4 | 12 | $A[i] ≤ 3$. |
| 5 | 13 | $W(0, N - 1,A[i]) ≤ 2$ (for each $i$ such that 0ドル ≤ i ≤ N - 1$) |
| 6 | 22 | $N ≤ 8 × 10^4$. |
| 7 | 18 | No additional constraints. |
The sample grader reads input in the following format:
The sample grader prints your output in the following format:
sequence.C++17, C++20, C++17 (Clang), C++20 (Clang)