QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#2570. 最大子序列

Statistics

定义一个序列的“美观度”(beauty)为其最长上升子序列的长度。

给定一个包含 $n$ 个整数的数组 $a$。请找出一个 $a$ 的子序列,使得该子序列的美观度严格小于原数组 $a$ 的美观度,并求出满足条件的最长子序列的长度。

输入格式

第一行包含一个整数 $n$,表示数组 $a$ 中元素的个数($1 \le n \le 5 \cdot 10^5$)。

第二行包含 $n$ 个用空格分隔的整数 $a_1, a_2, \dots, a_n$($1 \le a_i \le 10^9$)。

输出格式

输出一个整数:满足其美观度小于原数组 $a$ 美观度的子序列的最大长度。

样例

输入 1

3
2 1 3

输出 1

2

输入 2

4
4 3 2 1

输出 2

0

输入 3

4
2 1 4 3

输出 3

2

输入 4

6
4 6 5 2 1 3

输出 4

4

输入 5

4
3 4 1 2

输出 5

2

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#609Editorial Open集训队作业 解题报告 by 彭亦宸Qingyu2026-01-02 23:07:10 Download
#552Editorial Open集训队作业 解题报告 by 赵晟昊Qingyu2026-01-02 22:18:50 Download

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.