QOJ.ac

QOJ

Time Limit: 7 s Memory Limit: 1024 MB Total points: 100

#970. Dãy con tốt nhất

Statistics

Chúng ta gọi $W$ là một $k$-best number của dãy $B_{1 \dots m}$ nếu tồn tại một dãy $C_{1 \dots k}$ thỏa mãn hai điều kiện sau:

  1. $C_{1 \dots k}$ là một dãy con của $B_{1 \dots m}$.
  2. $\forall i \in [1, k], C_i + C_{(i \bmod k)+1} \leq W$.

Cho một dãy $A_{1 \dots n}$, bạn cần trả lời $Q$ câu hỏi. Mỗi câu hỏi bao gồm ba số nguyên $L, R, K$, và bạn cần tính giá trị $k$-best number nhỏ nhất của $A_{L \dots R}$.

Nhắc lại rằng $C$ là một dãy con của $B$ khi và chỉ khi ta có thể thu được $C$ bằng cách loại bỏ một số phần tử của $B$ (có thể không loại bỏ phần tử nào hoặc loại bỏ tất cả).

Dữ liệu vào

Dòng đầu tiên chứa hai số nguyên $n$ và $Q$ ($1 \leq n, Q \leq 10^5$). Dòng thứ hai chứa $n$ số nguyên $A_{1 \dots n}$ ($0 \leq A_i \leq 10^9$). Tiếp theo là $Q$ dòng. Mỗi dòng chứa ba số nguyên $L, R, K$, đại diện cho một câu hỏi ($1 \leq L \leq R \leq n$; $1 \leq K \leq R - L + 1$).

Dữ liệu ra

Với mỗi câu hỏi, in ra một dòng chứa một số nguyên duy nhất: kết quả.

Ví dụ

Dữ liệu vào 1

5 3
2 6 1 5 4
1 5 4
1 3 2
1 5 3

Dữ liệu ra 1

8
3
6

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#518Editorial Open集训队作业 解题报告 by 全柏锋Qingyu2026-01-02 21:37:15View PDF

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.