QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 32 MB مجموع النقاط: 10

#13518. 超级数

الإحصائيات

一个 $n$ 元排列是一个由集合 $1, 2, \dots, n$ 中互不相同的数字组成的 $n$ 元序列。例如,序列 2, 1, 4, 5, 3 是一个 5 元排列。

在数字排列中,我们对最长上升子序列感兴趣。在上述示例排列中,最长上升子序列的长度为 3,且恰好存在两个这样的子序列,即 2, 4, 5 和 1, 4, 5。

如果一个数字属于至少一个最长上升子序列,我们称其为超级数Superliczba)。在排列 2, 1, 4, 5, 3 中,超级数有 1, 2, 4, 5,而数字 3 不是超级数。

你的任务是对于给定的排列,找出所有的超级数。

任务

编写一个程序:

  • 从标准输入读取排列,
  • 找出所有的超级数,
  • 将找到的超级数输出到标准输出。

输入格式

输入包含两行。第一行包含一个整数 $n$($1 \le n \le 100\,000$)。第二行包含 $n$ 个由单个空格分隔的整数,构成一个 $n$ 元排列。

输出格式

输出应包含两行。第一行应包含一个整数 $m$,表示输入排列中超级数的个数。第二行应包含由单个空格分隔的超级数,并按升序排列。

样例

输入样例 1

5
2 1 4 5 3

输出样例 1

4
1 2 4 5

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.